The moonphase gem provides uses a simple calculation described by HAB on http://www.daniweb.com/code/snippet492.html to calculate the moon phase. One public method, <tt>getphase(arg)</tt>, takes a single argument that is either a Time or String type. The private method calcphase is invoked and modifies <tt>@phase</tt> Sections of this code were taken from the following: * Python code by HAB * http://www.daniweb.com/code/snippet492.html and translated into Ruby by Chase Southard on 4/4/2009
Calculates the phase of the moon based given a date.
require 'moonphase' t = Time.now moon = Moonphase::Moon.new moon.getphase(t) puts moon.phase or require 'moonphase' moon = Moonphase::Moon.new moon.getphase("4/11") puts moon.phase
Ruby 1.8.6 +
Ruby 1.9.1 has not been tested.
sudo gem install moonphase --source=http://gems.github.com
(The MIT License)
Copyright © 2009 Chase Southard
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.