calc_sun

<img src=“https://travis-ci.org/DouglasAllen/calc_sun.svg?branch=master” alt=“Build Status” />

Home

rubygems.org/gems/calc_sun

Code

github.com/DouglasAllen/calc_sun

RDoc

www.rubydoc.info/gems/calc_sun/1.2.10

Issues

github.com/DouglasAllen/calc_sun/issues

DESCRIPTION:

Calculate Sunrise, Noon, and Sunset using native C extension. An example is supplied to show this gem usage. Some new features added since version 1.2.6

INSTALL: Note: older version

$> gem install calc_sun

DOWNLOAD:

$> git clone https://github.com/DouglasAllen/calc_sun.git
$> cd calc_sun
$> bundle install

Build with DEVKIT

cd to devkit dir and run devkitvars.bat
or make a batchfile to start your envirnment with 'run devkitvars'
cd to calc_sun dir
$> gem build calc_sun.gemspec
$> gem install calc_sun-1.2.9.gem -l

DEVELOPERS:

After checking out the source, run:

$ bundle exec rake newb

This task will install any missing dependencies, run the tests/specs, and generate the RDoc.

FEATURES/PROBLEMS:

Consult issues if you want features or create pull requests.

SYNOPSIS:

start irb

$ irb --simple-prompt

enter Code

lat = 39.742476
lon = -105.1786
require 'calc_sun'
cs = CalcSun.new
# require 'date' included in CalcSun class
ajd = DateTime.new(2003, 10, 17, 12, 30, 30).ajd.to_f
puts cs.ajd2dt(ajd)
# set the date with set_date as date is just an ivar
day = cs.set_datetime('2003-10-17 12:30:30')
puts day.httpdate
puts "Sun rise: #{cs.rise(day.jd, lat, lon).httpdate}"
puts "Sun noon: #{cs.noon(day.jd, lat, lon).httpdate}"
puts "Sun set: #{cs.set(day.jd, lat, lon).httpdate}"
puts "Sun AJD rise: #{cs.rise_jd(day.jd, lat, lon)}"
puts "Sun AJD noon: #{cs.noon_jd(day.jd, lat, lon)}"
puts "Sun AJD set: #{cs.set_jd(day.jd, lat, lon)}"
puts "Sun azimuth rise: #{cs.rise_az(day.jd, lat, lon)}"
puts "Sun azimuth noon: #{cs.noon_az(day.jd, lat, lon)}"
puts "Sun azimuth set: #{cs.set_az(day.jd, lat, lon)}"

LICENSE:

(The MIT License)

Copyright © 2016

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.