Class: EarthTools::Result::SunriseSunset
- Defined in:
- lib/earth_tools/result/sunrise_sunset.rb
Overview
The sunrise/sunset result object
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
13 14 15 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 13 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
61 62 63 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 61 def evening_astronomical_twilight create_time @data['evening']['twilight']['astronomical'] end |
#evening_civil_twilight ⇒ Time
The evening civil twilight time
68 69 70 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 68 def evening_civil_twilight create_time @data['evening']['twilight']['civil'] end |
#evening_nautical_twilight ⇒ Time
The evening nautical twilight time
75 76 77 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 75 def evening_nautical_twilight create_time @data['evening']['twilight']['nautical'] end |
#evening_twilight(type) ⇒ Time
The evening twilight time for the specified type
54 55 56 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 54 def evening_twilight(type) twilight :evening, type end |
#morning_astronomical_twilight ⇒ Time
The morning astronomical twilight time
82 83 84 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 82 def morning_astronomical_twilight create_time @data['morning']['twilight']['astronomical'] end |
#morning_civil_twilight ⇒ Time
The morning civil twilight time
89 90 91 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 89 def morning_civil_twilight create_time @data['morning']['twilight']['civil'] end |
#morning_nautical_twilight ⇒ Time
The morning nautical twilight time
96 97 98 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 96 def morning_nautical_twilight create_time @data['morning']['twilight']['nautical'] end |
#morning_twilight(type) ⇒ Time
The morning twilight time for the specified type
46 47 48 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 46 def morning_twilight(type) twilight :morning, type end |
#sunrise ⇒ Time
The sunrise time
20 21 22 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 20 def sunrise create_time @data['morning']['sunrise'] end |
#sunset ⇒ Time
The sunset time
27 28 29 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 27 def sunset create_time @data['evening']['sunset'] end |
#twilight(time, type) ⇒ Time
The twilight time for the specified time and type
36 37 38 39 40 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 36 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.
104 105 106 |
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 104 def utc_offset @data['date']['timezone'].to_i end |