Class: UndergroundWeather::Astronomy

Inherits:
Object
  • Object
show all
Defined in:
lib/undergroundweather/features/astronomy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feed) ⇒ Astronomy

Returns a new instance of Astronomy.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/undergroundweather/features/astronomy.rb', line 5

def initialize(feed)
  phase = feed['moon_phase']
  
  @age_of_moon = phase['ageOfMoon']

  @raw_illuminated = phase['percentIlluminated']
  
  @raw_sunrise = { :hour => phase['sunrise']['hour'], :minute => phase['sunrise']['minute'] }
  @raw_sunset  = { :hour => phase['sunset']['hour'],  :minute => phase['sunset']['minute']  }
  
  @now = Time.new
end

Instance Attribute Details

#age_of_moonObject (readonly)

Returns the value of attribute age_of_moon.



3
4
5
# File 'lib/undergroundweather/features/astronomy.rb', line 3

def age_of_moon
  @age_of_moon
end

Instance Method Details

#illuminatedObject



18
19
20
# File 'lib/undergroundweather/features/astronomy.rb', line 18

def illuminated
  "#{@raw_illuminated}%"
end

#sunriseObject



22
23
24
# File 'lib/undergroundweather/features/astronomy.rb', line 22

def sunrise
  today_at_hour_and_minute(@raw_sunset)
end

#sunsetObject



26
27
28
# File 'lib/undergroundweather/features/astronomy.rb', line 26

def sunset
  today_at_hour_and_minute(@raw_sunrise)
end