Class: MobilyApiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/mobily/mobily_api_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, response_status) ⇒ MobilyApiResponse

Returns a new instance of MobilyApiResponse.



4
5
6
7
8
# File 'lib/mobily/mobily_api_response.rb', line 4

def initialize(status, response_status)
  @status = status
  @response_status = response_status.downcase
  @data = {}
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'lib/mobily/mobily_api_response.rb', line 2

def data
  @data
end

#response_statusObject

Returns the value of attribute response_status.



2
3
4
# File 'lib/mobily/mobily_api_response.rb', line 2

def response_status
  @response_status
end

#statusObject

Returns the value of attribute status.



2
3
4
# File 'lib/mobily/mobily_api_response.rb', line 2

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/mobily/mobily_api_response.rb', line 18

def == other
  eql?(other)
end

#add_data(key, value) ⇒ Object



10
11
12
# File 'lib/mobily/mobily_api_response.rb', line 10

def add_data(key, value)
  @data.merge!({key => value})
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/mobily/mobily_api_response.rb', line 22

def eql? other
  [@status, @response_status, @data].eql?([other.status, other.response_status, other.data])
end

#get(key) ⇒ Object



14
15
16
# File 'lib/mobily/mobily_api_response.rb', line 14

def get(key)
  @data.has_key?(key) ? @data[key] : nil
end