Class: SimpleOpenWeatherMap::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_open_weather_map/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Report

Returns a new instance of Report.



5
6
7
8
9
10
11
12
13
# File 'lib/simple_open_weather_map/report.rb', line 5

def initialize(config)
  if config.is_a?(Hash) then
    @config = SimpleOpenWeatherMap::Config.new(config)
  elsif config.is_a?(SimpleOpenWeatherMap::Config) then
    @config = config
  else
    raise "config should be Hash or SimpleOpenWeatherMap::Config object."
  end
end

Instance Attribute Details

#city_idObject

Returns the value of attribute city_id.



3
4
5
# File 'lib/simple_open_weather_map/report.rb', line 3

def city_id
  @city_id
end

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/simple_open_weather_map/report.rb', line 3

def config
  @config
end

Instance Method Details

#currentObject



17
18
19
# File 'lib/simple_open_weather_map/report.rb', line 17

def current
    weather.current(@config)
end

#forecastObject



21
22
23
# File 'lib/simple_open_weather_map/report.rb', line 21

def forecast
    weather.forecast(@config)
end

#puts_reportObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/simple_open_weather_map/report.rb', line 25

def puts_report
  puts format_current(current)
  puts ""

  cnt = 0
  forecast["list"].each do |data|
    if cnt != 0 then
      puts format_forecast(data)
    end

    cnt += 1
  end
end