Class: OpenWeatherApi::Current

Inherits:
Object
  • Object
show all
Defined in:
lib/open_weather_api/current.rb

Instance Method Summary collapse

Constructor Details

#initialize(current) ⇒ Current

Returns a new instance of Current.



3
4
5
# File 'lib/open_weather_api/current.rb', line 3

def initialize(current)
  @current_hash = current.parsed_response
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/open_weather_api/current.rb', line 11

def method_missing(name, *args, &block)
  if @current_hash.respond_to? name
    @current_hash.send(name)
  elsif @current_hash.has_key?(name.to_s)
    @current_hash[name.to_s]
  else
    super
  end
end

Instance Method Details

#[](key) ⇒ Object



7
8
9
# File 'lib/open_weather_api/current.rb', line 7

def [](key)
  @current_hash[key]
end