Class: Accuweather::Conditions::ForecastDay

Inherits:
Object
  • Object
show all
Defined in:
lib/accuweather/conditions/forecast_day.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, day_of_week:, sunrise:, sunset:, daytime:, nighttime:) ⇒ ForecastDay

Returns a new instance of ForecastDay.



6
7
8
9
10
11
12
13
# File 'lib/accuweather/conditions/forecast_day.rb', line 6

def initialize(date:, day_of_week:, sunrise:, sunset:, daytime:, nighttime:)
  @date = date
  @day_of_week = day_of_week
  @sunrise = sunrise
  @sunset = sunset
  @daytime = daytime
  @nighttime = nighttime
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



4
5
6
# File 'lib/accuweather/conditions/forecast_day.rb', line 4

def date
  @date
end

#day_of_weekObject (readonly)

Returns the value of attribute day_of_week.



4
5
6
# File 'lib/accuweather/conditions/forecast_day.rb', line 4

def day_of_week
  @day_of_week
end

#daytimeObject (readonly)

Returns the value of attribute daytime.



4
5
6
# File 'lib/accuweather/conditions/forecast_day.rb', line 4

def daytime
  @daytime
end

#nighttimeObject (readonly)

Returns the value of attribute nighttime.



4
5
6
# File 'lib/accuweather/conditions/forecast_day.rb', line 4

def nighttime
  @nighttime
end

#sunriseObject (readonly)

Returns the value of attribute sunrise.



4
5
6
# File 'lib/accuweather/conditions/forecast_day.rb', line 4

def sunrise
  @sunrise
end

#sunsetObject (readonly)

Returns the value of attribute sunset.



4
5
6
# File 'lib/accuweather/conditions/forecast_day.rb', line 4

def sunset
  @sunset
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/accuweather/conditions/forecast_day.rb', line 15

def ==(other)
  date == other.date &&
    day_of_week == other.day_of_week &&
    sunrise == other.sunrise &&
    sunset == other.sunset &&
    daytime == other.daytime &&
    nighttime == other.nighttime
rescue NoMethodError
  false
end

#to_sObject



26
27
28
# File 'lib/accuweather/conditions/forecast_day.rb', line 26

def to_s
  "date: #{date}, day_of_week: #{day_of_week}, sunrise: #{sunrise}, sunset: #{sunset}, daytime: #{daytime}, nighttime: #{nighttime}"
end