Class: SimpleOpenWeatherMap::Report
- Inherits:
-
Object
- Object
- SimpleOpenWeatherMap::Report
- Defined in:
- lib/simple_open_weather_map/report.rb
Instance Attribute Summary collapse
-
#city_id ⇒ Object
Returns the value of attribute city_id.
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #current ⇒ Object
- #forecast ⇒ Object
-
#initialize(config) ⇒ Report
constructor
A new instance of Report.
- #puts_report ⇒ Object
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_id ⇒ Object
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 |
#config ⇒ Object
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
#current ⇒ Object
17 18 19 |
# File 'lib/simple_open_weather_map/report.rb', line 17 def current weather.current(@config) end |
#forecast ⇒ Object
21 22 23 |
# File 'lib/simple_open_weather_map/report.rb', line 21 def forecast weather.forecast(@config) end |
#puts_report ⇒ Object
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 |