Class: SunTime

Inherits:
Object
  • Object
show all
Includes:
DegreeTrig
Defined in:
lib/sun_time.rb,
lib/sun_time/degree_trig.rb

Defined Under Namespace

Modules: DegreeTrig Classes: AlwaysDarkError, AlwaysLightError

Constant Summary collapse

VERSION =
'0.0.2'
MEAN_SOLAR_ANOMALY_DELTA =
0.000001

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DegreeTrig

#acos, #asin, #atan, #cos, #d2r, #r2d, #sin, #tan

Constructor Details

#initialize(date, lat, lng) ⇒ SunTime

Returns a new instance of SunTime.



14
15
16
17
18
19
# File 'lib/sun_time.rb', line 14

def initialize (date, lat, lng)
  @date = date
  @lat = lat
  @lng = lng
  @m = nil
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



12
13
14
# File 'lib/sun_time.rb', line 12

def date
  @date
end

#latObject (readonly)

Returns the value of attribute lat.



12
13
14
# File 'lib/sun_time.rb', line 12

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng.



12
13
14
# File 'lib/sun_time.rb', line 12

def lng
  @lng
end

Instance Method Details

#sunriseObject



21
22
23
24
25
# File 'lib/sun_time.rb', line 21

def sunrise
  jd2time j_rise
rescue AlwaysDarkError, AlwaysLightError
  nil
end

#sunsetObject



27
28
29
30
31
# File 'lib/sun_time.rb', line 27

def sunset
  jd2time j_set
rescue AlwaysDarkError, AlwaysLightError
  nil
end