class SolCal::Location

Public Class Methods

new(latitude, longitude) click to toggle source
# File lib/solcal/location.rb, line 3
def initialize(latitude, longitude)
        @latitude, @longitude = Angle.from_deg(latitude), Angle.from_deg(longitude)
end

Public Instance Methods

angle_to_zenith_at_time(year, month, day, hour, minute, time_zone) click to toggle source
# File lib/solcal/location.rb, line 29
def angle_to_zenith_at_time(year, month, day, hour, minute, time_zone)
        results = create_data(year, month, day, time_zone)
        results[:at_time] = (hour*60.0+minute)/(24*60.0)
        Commands.run(:angle_to_zenith_at_time, results)
        results
end
date_pair(year, month, day, time_zone) click to toggle source
# File lib/solcal/location.rb, line 36
def date_pair(year, month, day, time_zone)
        results = create_data(year,month,day, time_zone)
        Commands.run(:duration, results)
        date = Date.new(year, month, day)
        while(date <= Date.new(year+1, month, day))
                date += 1
                next_results = create_data(date.year, date.month, date.day, time_zone)
                Commands.run(:duration, next_results)
                return next_results if (results[:duration]-next_results[:duration]).abs <= 0.3
        end
end
daylight(year,month,day,time_zone) click to toggle source
# File lib/solcal/location.rb, line 11
def daylight(year,month,day,time_zone)
        results = create_data(year,month,day, time_zone)
        Commands.run(:sunrise, results)
        Commands.run(:sunset, results)
        Commands.run(:duration, results)
        Commands.run(:civil_dawn, results)
        Commands.run(:civil_dusk, results)
        results
end
method_missing(name, *args, &block) click to toggle source
# File lib/solcal/location.rb, line 7
def method_missing(name, *args, &block)
        Commands.run(name, create_data(args[0],args[1],args[2],args[3]))
end
time_to_angle_from_zenith(year, month, day, time_zone, angle_from_zenith) click to toggle source
# File lib/solcal/location.rb, line 21
def time_to_angle_from_zenith(year, month, day, time_zone, angle_from_zenith)
        results = create_data(year, month, day, time_zone)
        results[:angle_from_zenith] = angle_from_zenith
        Commands.run(:time_to_angle_from_zenith, results)
        Commands.run(:opposite_time_to_angle_from_zenith, results)
        results
end

Protected Instance Methods

create_data(year, month, day, time_zone) click to toggle source
# File lib/solcal/location.rb, line 49
def create_data(year, month, day, time_zone)
         {
                latitude: @latitude,
                longitude: @longitude,
                time_zone: time_zone,
                date: Date.new(year,month,day)
        }
end