Class: EarthTools::Result::SunriseSunset
- Defined in:
- lib/earth_tools/result/sunrise_sunset.rb
Overview
The sunrise/sunset result.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#date ⇒ Hash
The date of the sunrise/sunset data as a hash.
-
#evening_astronomical_twilight ⇒ Time
The evening astronomical twilight time.
-
#evening_civil_twilight ⇒ Time
The evening civil twilight time.
-
#evening_nautical_twilight ⇒ Time
The evening nautical twilight time.
-
#evening_twilight(type) ⇒ Time
The evening twilight time for the specified type.
-
#morning_astronomical_twilight ⇒ Time
The morning astronomical twilight time.
-
#morning_civil_twilight ⇒ Time
The morning civil twilight time.
-
#morning_nautical_twilight ⇒ Time
The morning nautical twilight time.
-
#morning_twilight(type) ⇒ Time
The morning twilight time for the specified type.
-
#sunrise ⇒ Time
The sunrise time.
-
#sunset ⇒ Time
The sunset time.
-
#twilight(time, type) ⇒ Time
The twilight time for the specified time and type.
-
#utc_offset ⇒ Integer
The number of hours offset from UTC disregarding any correction for daylight saving time See http://en.wikipedia.org/wiki/UTC_offset.
Methods inherited from Base
#initialize, #latitude, #location, #longitude, #version
Constructor Details
This class inherits a constructor from EarthTools::Result::Base
Instance Method Details
#date ⇒ Hash
The date of the sunrise/sunset data as a hash
12 13 14 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 12 def date { :year => Time.now.year, :month => @data['date']['month'].to_i, :day => @data['date']['day'].to_i } end |
#evening_astronomical_twilight ⇒ Time
The evening astronomical twilight time
60 61 62 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 60 def evening_astronomical_twilight create_time @data['evening']['twilight']['astronomical'] end |
#evening_civil_twilight ⇒ Time
The evening civil twilight time
67 68 69 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 67 def evening_civil_twilight create_time @data['evening']['twilight']['civil'] end |
#evening_nautical_twilight ⇒ Time
The evening nautical twilight time
74 75 76 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 74 def evening_nautical_twilight create_time @data['evening']['twilight']['nautical'] end |
#evening_twilight(type) ⇒ Time
The evening twilight time for the specified type
53 54 55 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 53 def evening_twilight(type) twilight :evening, type end |
#morning_astronomical_twilight ⇒ Time
The morning astronomical twilight time
81 82 83 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 81 def morning_astronomical_twilight create_time @data['morning']['twilight']['astronomical'] end |
#morning_civil_twilight ⇒ Time
The morning civil twilight time
88 89 90 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 88 def morning_civil_twilight create_time @data['morning']['twilight']['civil'] end |
#morning_nautical_twilight ⇒ Time
The morning nautical twilight time
95 96 97 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 95 def morning_nautical_twilight create_time @data['morning']['twilight']['nautical'] end |
#morning_twilight(type) ⇒ Time
The morning twilight time for the specified type
45 46 47 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 45 def morning_twilight(type) twilight :morning, type end |
#sunrise ⇒ Time
The sunrise time
19 20 21 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 19 def sunrise create_time @data['morning']['sunrise'] end |
#sunset ⇒ Time
The sunset time
26 27 28 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 26 def sunset create_time @data['evening']['sunset'] end |
#twilight(time, type) ⇒ Time
The twilight time for the specified time and type
35 36 37 38 39 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 35 def twilight(time, type) time = time.to_sym if time.is_a?(String) type = type.to_sym if type.is_a?(String) send "#{time}_#{type}_twilight" if [:morning, :evening].include?(time) && [:astronomical, :civil, :nautical].include?(type) end |
#utc_offset ⇒ Integer
The number of hours offset from UTC disregarding any correction for daylight saving time See http://en.wikipedia.org/wiki/UTC_offset.
103 104 105 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 103 def utc_offset @data['date']['timezone'].to_i end |