Class: WeatherReport::Day
- Inherits:
-
Object
- Object
- WeatherReport::Day
- Defined in:
- lib/weather-report/day.rb
Instance Attribute Summary collapse
-
#date ⇒ Date
readonly
The date.
-
#telop ⇒ String
readonly
The telop.
-
#temperature_max ⇒ Fixnum
readonly
Temperature of today could be nil.
-
#temperature_min ⇒ Fixnum
readonly
Temperature of today could be nil.
Instance Method Summary collapse
-
#initialize(forecasts, dateLabel) ⇒ Day
constructor
A new instance of Day.
-
#rain? ⇒ Boolean
Return true if it rains.
-
#snow? ⇒ Boolean
Return true if it snows.
-
#to_h ⇒ Hash
Return with hash format.
-
#umbrella? ⇒ Boolean
Return true if it will be rainy or snowy or sleety or hailstorm.
Constructor Details
#initialize(forecasts, dateLabel) ⇒ Day
Returns a new instance of Day.
7 8 9 |
# File 'lib/weather-report/day.rb', line 7 def initialize(forecasts, dateLabel) @forecast = forecast(forecasts, dateLabel) end |
Instance Attribute Details
#date ⇒ Date (readonly)
Returns the date.
27 28 29 |
# File 'lib/weather-report/day.rb', line 27 def date @date end |
#telop ⇒ String (readonly)
Returns the telop.
33 34 35 |
# File 'lib/weather-report/day.rb', line 33 def telop @telop end |
#temperature_max ⇒ Fixnum (readonly)
Temperature of today could be nil.
47 48 49 |
# File 'lib/weather-report/day.rb', line 47 def temperature_max @temperature_max end |
#temperature_min ⇒ Fixnum (readonly)
Temperature of today could be nil.
39 40 41 |
# File 'lib/weather-report/day.rb', line 39 def temperature_min @temperature_min end |
Instance Method Details
#rain? ⇒ Boolean
Return true if it rains.
12 13 14 |
# File 'lib/weather-report/day.rb', line 12 def rain? telop =~ /[雨]/ ? true : false end |
#snow? ⇒ Boolean
Return true if it snows.
17 18 19 |
# File 'lib/weather-report/day.rb', line 17 def snow? telop =~ /[雪]/ ? true : false end |
#to_h ⇒ Hash
Return with hash format.
54 55 56 57 58 59 60 61 |
# File 'lib/weather-report/day.rb', line 54 def to_h { "date" => date.to_s, "telop" => telop, "temperature_min" => temperature_min, "temperature_max" => temperature_max } end |
#umbrella? ⇒ Boolean
Return true if it will be rainy or snowy or sleety or hailstorm
22 23 24 |
# File 'lib/weather-report/day.rb', line 22 def umbrella? telop =~ /[雨雪霙雹]/ ? true : false end |