Class: MoonCalc

Inherits:
Object
  • Object
show all
Defined in:
lib/moon_calc.rb

Overview

Lunar/Moon phases ruby class

Code is based upon Bradley E. Schaefer”s moon phase algorithm. Ruby version based on JavaScript Phase Calculator by Stephen R. Schmitt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(epoch = Time.now) ⇒ MoonCalc

Return the current (or input a date) moon.

Moon.new
Moon.new(some_day)

Methods available:

phase    => Phase of the moon as a sym
days     => Moon days
icon     => An integer from 0 to 29
dist     => Distance in earth radii
ll       => Moon ecliptic lat/lon


19
20
21
22
# File 'lib/moon_calc.rb', line 19

def initialize(epoch=Time.now)
  @epoch = epoch
  do_calc
end

Instance Attribute Details

#daysObject (readonly)

Returns the value of attribute days.



6
7
8
# File 'lib/moon_calc.rb', line 6

def days
  @days
end

#distObject (readonly)

Returns the value of attribute dist.



6
7
8
# File 'lib/moon_calc.rb', line 6

def dist
  @dist
end

#epochObject (readonly)

Returns the value of attribute epoch.



6
7
8
# File 'lib/moon_calc.rb', line 6

def epoch
  @epoch
end

#iconObject (readonly)

Returns the value of attribute icon.



6
7
8
# File 'lib/moon_calc.rb', line 6

def icon
  @icon
end

#llObject (readonly)

Returns the value of attribute ll.



6
7
8
# File 'lib/moon_calc.rb', line 6

def ll
  @ll
end

#phaseObject (readonly)

Returns the value of attribute phase.



6
7
8
# File 'lib/moon_calc.rb', line 6

def phase
  @phase
end