class TimeDoctor::TimeDoctorError
Attributes
body[R]
code[R]
message[R]
Public Class Methods
new(response)
click to toggle source
# File lib/timedoctor/exceptions.rb, line 3 def initialize(response) @code = response.status @body = JSON.parse(response.body) @message = create_message end
Private Instance Methods
create_message()
click to toggle source
# File lib/timedoctor/exceptions.rb, line 13 def create_message message = indent("Code: #{@code}") @body.delete('code') @body.each { |k, v| message << indent("#{format k}: #{format v}") } message end
format(str)
click to toggle source
# File lib/timedoctor/exceptions.rb, line 24 def format(str) str.tr('_', ' ').capitalize rescue NoMethodError str end
indent(str)
click to toggle source
# File lib/timedoctor/exceptions.rb, line 20 def indent(str) "\n #{str}" end