Class: EarthTools::Result::SunriseSunset

Inherits:
Base
  • Object
show all
Defined in:
lib/earth_tools/result/sunrise_sunset.rb

Overview

The sunrise/sunset result object

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #latitude, #location, #longitude, #version

Constructor Details

This class inherits a constructor from EarthTools::Result::Base

Instance Method Details

#dateHash

The date of the sunrise/sunset data as a hash

Returns:

  • (Hash)

    Hash containing year, month, and day as integers



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_twilightTime

The evening astronomical twilight time

Returns:

  • (Time)

    the astronomical twilight time for the evening



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_twilightTime

The evening civil twilight time

Returns:

  • (Time)

    the civil twilight time for the evening



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_twilightTime

The evening nautical twilight time

Returns:

  • (Time)

    the nautical twilight time for the evening



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

Parameters:

  • the (Symbol)

    type of evening twilight time

Returns:

  • (Time)

    the specified evening twilight time



54
55
56
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 54

def evening_twilight(type)
  twilight :evening, type
end

#morning_astronomical_twilightTime

The morning astronomical twilight time

Returns:

  • (Time)

    the astronomical twilight time for the morning



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_twilightTime

The morning civil twilight time

Returns:

  • (Time)

    the civil twilight time for the morning



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_twilightTime

The morning nautical twilight time

Returns:

  • (Time)

    the nautical twilight time for the morning



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

Parameters:

  • the (Symbol)

    type of morning twilight time

Returns:

  • (Time)

    the specified morning twilight time



46
47
48
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 46

def morning_twilight(type)
  twilight :morning, type
end

#sunriseTime

The sunrise time

Returns:

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

#sunsetTime

The sunset time

Returns:

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

Parameters:

  • the (Symbol)

    time (:morning or :evening)

  • the (Symbol)

    type (:astronomical, :civil, or :nautical)

Returns:

  • (Time)

    the requested twilight time



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_offsetInteger

The number of hours offset from UTC disregarding any correction for daylight saving time See http://en.wikipedia.org/wiki/UTC_offset.

Returns:

  • (Integer)

    the UTC offset



104
105
106
# File 'lib/earth_tools/result/sunrise_sunset.rb', line 104

def utc_offset
  @data['date']['timezone'].to_i
end