Class: GoogleWeather::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/google_weather/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Data

Returns a new instance of Data.



5
6
7
# File 'lib/google_weather/data.rb', line 5

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



9
10
11
12
# File 'lib/google_weather/data.rb', line 9

def method_missing(method)
  key = data[method.to_s]
  key && key['data']
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/google_weather/data.rb', line 3

def data
  @data
end

Instance Method Details

#inspectObject



14
15
16
17
# File 'lib/google_weather/data.rb', line 14

def inspect
  data = @data.inject([]) { |collection, key| collection << "#{key[0]}: #{key[1]['data']}"; collection }.join("\n    ")
  "#<#{self.class}:0x#{object_id}\n    #{data}>"
end