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)

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

- (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
18
19
20
21
# File 'lib/google_weather/data.rb', line 14

def inspect
  begin
    data = @data.inject([]) { |collection, key| collection << "#{key[0]}: #{key[1]['data']}"; collection }.join("\n    ")
    "#<#{self.class}:0x#{object_id}\n    #{data}>"
  rescue
    "No weather information found for the specified location."
  end
end