Class: USNO::Transit::View

Inherits:
PayDirt::Base
  • Object
show all
Defined in:
lib/usno/transit.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ View

Returns a new instance of View.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/usno/transit.rb', line 23

def initialize(options = {})
  raise "Cannot instantiate this class directly" if self.class.name == "View"

  # Default options
  options = {
    request_class: USNO::Transit::USRequest,
    object: USNO::Transit::BODIES.fetch(self.class.name.split("::")[-1]) {
      raise "Celestial object not recognized"
    },
    z_meters: 0,
    date: Time.now,
    days: 5,
  }.merge(options)

  load_options(:city, :state, options)
end

Instance Method Details

#callObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/usno/transit.rb', line 40

def call
  result(true, @request_class.new({
    obj: @object,
    city: @city,
    state: USNO::Transit::States.by_key_or_value(@state),
    z_meters: @z_meters,
    date: @date,
    days: @days
  }).call.data)
end