Class: GoogleWeather::Data

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

Direct Known Subclasses

CurrentConditions, ForecastCondition, ForecastInformation

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Data) initialize(data)

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

- (Object) method_missing(method)



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

- (Object) data (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

- (Object) inspect



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