Class: WeatherJp::Weather
- Inherits:
-
Object
- Object
- WeatherJp::Weather
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/weather_jp/weather.rb
Instance Attribute Summary collapse
-
#city ⇒ WeatherJp::City
readonly
The current value of city.
-
#current ⇒ WeatherJp::DayWeather
readonly
The current value of current.
-
#day_after_tomorrow ⇒ WeatherJp::DayWeather
readonly
The current value of day_after_tomorrow.
-
#today ⇒ WeatherJp::DayWeather
readonly
The current value of today.
-
#tomorrow ⇒ WeatherJp::DayWeather
readonly
The current value of tomorrow.
-
#weathers ⇒ Array<WeatherJp::DayWeather>
(also: #day_weathers, #to_a)
readonly
The current value of weathers.
Instance Method Summary collapse
- #each {|WeatherJp::DayWeather| ... } ⇒ WeatherJp::Weather
- #each_with_all {|WeatherJp::DayWeather| ... } ⇒ WeatherJp::Weather
- #each_without_current {|WeatherJp::DayWeather| ... } ⇒ WeatherJp::Weather
-
#except_current ⇒ Array<WeatherJp::DayWeather>
Except current weather status.
- #for(date) ⇒ WeatherJp::DayWeather? (also: #get_weather)
-
#initialize(city, weathers) ⇒ Weather
constructor
A new instance of Weather.
Constructor Details
#initialize(city, weathers) ⇒ Weather
Returns a new instance of Weather.
27 28 29 30 |
# File 'lib/weather_jp/weather.rb', line 27 def initialize(city, weathers) @city = city @weathers = weathers end |
Instance Attribute Details
#city ⇒ WeatherJp::City (readonly)
Returns the current value of city.
8 9 10 |
# File 'lib/weather_jp/weather.rb', line 8 def city @city end |
#current ⇒ WeatherJp::DayWeather (readonly)
Returns the current value of current.
8 9 10 |
# File 'lib/weather_jp/weather.rb', line 8 def current @current end |
#day_after_tomorrow ⇒ WeatherJp::DayWeather (readonly)
Returns the current value of day_after_tomorrow.
8 9 10 |
# File 'lib/weather_jp/weather.rb', line 8 def day_after_tomorrow @day_after_tomorrow end |
#today ⇒ WeatherJp::DayWeather (readonly)
Returns the current value of today.
8 9 10 |
# File 'lib/weather_jp/weather.rb', line 8 def today @today end |
#tomorrow ⇒ WeatherJp::DayWeather (readonly)
Returns the current value of tomorrow.
8 9 10 |
# File 'lib/weather_jp/weather.rb', line 8 def tomorrow @tomorrow end |
#weathers ⇒ Array<WeatherJp::DayWeather> (readonly) Also known as: day_weathers, to_a
Returns the current value of weathers.
8 9 10 |
# File 'lib/weather_jp/weather.rb', line 8 def weathers @weathers end |
Instance Method Details
#each {|WeatherJp::DayWeather| ... } ⇒ WeatherJp::Weather
34 35 36 |
# File 'lib/weather_jp/weather.rb', line 34 def each(&block) each_with_all(&block) end |
#each_with_all {|WeatherJp::DayWeather| ... } ⇒ WeatherJp::Weather
40 41 42 43 |
# File 'lib/weather_jp/weather.rb', line 40 def each_with_all weathers.each {|i| yield i } self end |
#each_without_current {|WeatherJp::DayWeather| ... } ⇒ WeatherJp::Weather
47 48 49 50 |
# File 'lib/weather_jp/weather.rb', line 47 def each_without_current except_current.each {|i| yield i } self end |
#except_current ⇒ Array<WeatherJp::DayWeather>
Except current weather status.
54 55 56 |
# File 'lib/weather_jp/weather.rb', line 54 def except_current weathers.reject {|w| w.date_code == -1 } end |
#for(date) ⇒ WeatherJp::DayWeather? Also known as: get_weather
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/weather_jp/weather.rb', line 60 def for(date) case date when Date raise NotImplementedError when :current day = 0 when :today day = 1 when :tomorrow day = 2 when :day_after_tomorrow day = 3 else day = date + 1 end weathers[day] end |