Class: Latitude::APIError::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/latitude/api/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Entry

Returns a new instance of Entry.



21
22
23
24
25
26
27
28
# File 'lib/latitude/api/errors.rb', line 21

def initialize(raw)
  @raw    = raw || {}
  @status = @raw["status"]
  @code   = @raw["code"]
  @title  = @raw["title"]
  @detail = @raw["detail"] || @raw["message"]
  @meta   = @raw["meta"] || {}
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



19
20
21
# File 'lib/latitude/api/errors.rb', line 19

def code
  @code
end

#detailObject (readonly)

Returns the value of attribute detail.



19
20
21
# File 'lib/latitude/api/errors.rb', line 19

def detail
  @detail
end

#metaObject (readonly)

Returns the value of attribute meta.



19
20
21
# File 'lib/latitude/api/errors.rb', line 19

def meta
  @meta
end

#rawObject (readonly)

Returns the value of attribute raw.



19
20
21
# File 'lib/latitude/api/errors.rb', line 19

def raw
  @raw
end

#statusObject (readonly)

Returns the value of attribute status.



19
20
21
# File 'lib/latitude/api/errors.rb', line 19

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title.



19
20
21
# File 'lib/latitude/api/errors.rb', line 19

def title
  @title
end

Instance Method Details

#to_hObject



37
38
39
# File 'lib/latitude/api/errors.rb', line 37

def to_h
  @raw.dup
end

#to_sObject



30
31
32
33
34
35
# File 'lib/latitude/api/errors.rb', line 30

def to_s
  return @detail.to_s if @title.nil? || @title.empty?
  return @title.to_s if @detail.nil? || @detail.empty?

  "#{@title}: #{@detail}"
end