Class: WeatherReport::Day

Inherits:
Object
  • Object
show all
Defined in:
lib/weather-report/day.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dateDate (readonly)

Returns the date.

Returns:

  • (Date)

    the date



27
28
29
# File 'lib/weather-report/day.rb', line 27

def date
  @date
end

#telopString (readonly)

Returns the telop.

Returns:

  • (String)

    the telop



33
34
35
# File 'lib/weather-report/day.rb', line 33

def telop
  @telop
end

#temperature_maxFixnum (readonly)

Temperature of today could be nil.

Returns:

  • (Fixnum)

    the maximum temperature.



47
48
49
# File 'lib/weather-report/day.rb', line 47

def temperature_max
  @temperature_max
end

#temperature_minFixnum (readonly)

Temperature of today could be nil.

Returns:

  • (Fixnum)

    the minimum temperature.



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.

Returns:

  • (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.

Returns:

  • (Boolean)

    return true if it snows.



17
18
19
# File 'lib/weather-report/day.rb', line 17

def snow?
  telop =~ /[雪]/ ? true : false
end

#to_hHash

Return with hash format.

Returns:

  • (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

Returns:

  • (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