class USNO::Imagery::Earth::View
Public Class Methods
new(options = {})
click to toggle source
# File lib/usno/imagery/earth/view.rb, line 7 def initialize(options = {}) options = { time: Time.now, root_url: "http://api.usno.navy.mil/", resource: self.class.name.downcase.split("::")[1..-2].join("/") + ".png" }.merge(options) # sets instance variables from key value pairs, # will fail if any keys given before options aren't in options load_options(:time, :root_url, :resource, :view, options) and validate_state end
Public Instance Methods
call()
click to toggle source
# File lib/usno/imagery/earth/view.rb, line 19 def call result(true, query_for(@root_url + @resource)) end
Private Instance Methods
date()
click to toggle source
# File lib/usno/imagery/earth/view.rb, line 28 def date @time.utc.strftime("%m/%d/%Y") end
query_for(resource)
click to toggle source
# File lib/usno/imagery/earth/view.rb, line 24 def query_for(resource) "#{ resource }?view=#{ @view }" + time end
time()
click to toggle source
# File lib/usno/imagery/earth/view.rb, line 32 def time @time ? "&date=#{ date }&time=#{ @time.utc.strftime("%k:%M").lstrip }" : "" end
validate_state()
click to toggle source
# File lib/usno/imagery/earth/view.rb, line 36 def validate_state ["full", "moon", "sun", "rise", "set"].include? @view or raise( ":view not recognized - #{@view}" ) end