require 'bigdecimal' require 'calc_sun' require 'date' require 'eot' # This is for equationoftime gem but conversion is in process. # class AnalemmaDataTable attr_accessor :year, :eot, :finish, :start, :span, :page, :table def initialize @year = Time.now.utc.year @eot = Eot.new @cs = CalcSun.new @start = Date.parse("#{@year}-1-1") @finish = Date.parse("#{@year}-12-31") @span = 0..(@finish - @start).to_i @page = '' @page << '' @page << '' build end def page_head @page << "

Analemma Data for #{@year}

" @page << '
' @page << '' @page << '' @page << '' @page << '' @page << '' end def table_head @page << '' @page << '' @page << '' @page << '' @page << '' @page << '' @page << '' end def setup_each_iteration(inc) @cs.jd(@start + inc) @eot.jd = (@start + inc).jd + 0.5 @eot.ajd = (@start + inc).ajd + 0.5 @eot.ma_ta_set end def table_data(inc) @page << "" @page << "" @page << "" @page << "" @page << "" end def table_body @span.each do |i| setup_each_iteration(i) @page << '' @page << "" @page << "" @page << "" table_data(i) end end def table_foot @page << '' @page << '
yday date Julian No. Oblique ΔT Orbital ΔT Total ΔT Right Ascension Declination
#{@eot.show_minutes(@eot.time_delta_oblique)}#{@eot.show_minutes(@eot.time_delta_orbit)}#{@eot.show_minutes(@eot.time_eot)}#{@eot.string_time((@eot.ra_sun * Eot::R2D) / 15.0)}#{@cs.declination(inc)}
#{(@start + i).yday}#{(@start + i).month}/#{(@start + i).day}#{(@start + i).jd}.0
' end def build page_head table_head table_body table_foot @page << '' end end p AnalemmaDataTable.new