Class: IpwhoApi::IpGeoResponse
- Inherits:
-
Struct
- Object
- Struct
- IpwhoApi::IpGeoResponse
- Defined in:
- lib/ipwho.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#message ⇒ Object
Returns the value of attribute message.
-
#success ⇒ Object
Returns the value of attribute success.
Class Method Summary collapse
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
190 191 192 |
# File 'lib/ipwho.rb', line 190 def data @data end |
#message ⇒ Object
Returns the value of attribute message
190 191 192 |
# File 'lib/ipwho.rb', line 190 def @message end |
#success ⇒ Object
Returns the value of attribute success
190 191 192 |
# File 'lib/ipwho.rb', line 190 def success @success end |
Class Method Details
.from_hash(hash) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/ipwho.rb', line 191 def self.from_hash(hash) data_obj = nil if hash["data"].is_a?(Hash) # Bulk: normalise responseArray if hash["data"]["responseArray"].is_a?(Array) data_obj = hash["data"].dup data_obj["responseArray"] = hash["data"]["responseArray"].map { |item| IpGeoResponse.from_hash(item) } data_obj = OpenStruct.new(data_obj) else data_obj = GeoData.from_hash(hash["data"]) end end new(success: hash["success"], data: data_obj, message: hash["message"]) end |