Skip to content

Instantly share code, notes, and snippets.

@DouglasAllen
Last active August 29, 2015 14:15
Show Gist options
  • Save DouglasAllen/da72ed08285e33a2ed96 to your computer and use it in GitHub Desktop.
Save DouglasAllen/da72ed08285e33a2ed96 to your computer and use it in GitHub Desktop.
class Eot
attr_accessor :date, :lat, :lng, :attributes
def initialize attributes
@attributes = []
attributes.each_key do |k|
self.send("#{k}=", attributes[k])
@attributes << attributes[k]
end
end
def self.new_method name
send(:define_method, name) {yield}
end
end
require 'date'
params = {:date => DateTime.now.to_time.utc.to_datetime.to_s,
:time => DateTime.now.to_time.utc.to_datetime.day_fraction,
:lat => 41.5,
:lng => -88.930
}
eot = Eot.new(params)
ajd = Eot.new_method("ajd") {DateTime.parse(eot.attributes[0]).ajd.to_f + eot.attributes[1]}
jd = Eot.new_method("jd") {DateTime.parse(eot.attributes[0]).jd.to_f}
p ajd.call
p jd.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment