Class: Barometer::Response::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/barometer/response/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



22
23
24
25
# File 'lib/barometer/response/base.rb', line 22

def initialize
  super
  @requested_at = Time.now.utc
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



20
21
22
# File 'lib/barometer/response/base.rb', line 20

def current
  @current
end

#forecastObject

Returns the value of attribute forecast.



20
21
22
# File 'lib/barometer/response/base.rb', line 20

def forecast
  @forecast
end

Instance Method Details

#add_query(query) ⇒ Object



39
40
41
42
43
44
# File 'lib/barometer/response/base.rb', line 39

def add_query(query)
  return unless query
  @query = query.to_s
  @format = query.format
  @metric = query.metric?
end

#complete?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/barometer/response/base.rb', line 31

def complete?
  current && current.complete?
end

#for(date = nil) ⇒ Object



35
36
37
# File 'lib/barometer/response/base.rb', line 35

def for(date=nil)
  forecast.for(date || today)
end

#metric?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/barometer/response/base.rb', line 46

def metric?
  !!@metric
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/barometer/response/base.rb', line 27

def success?
  status_code == 200
end