Class: BoxcarPublisher::Push
- Inherits:
-
Object
- Object
- BoxcarPublisher::Push
- Defined in:
- lib/boxcar_publisher.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(options) ⇒ Push
constructor
A new instance of Push.
- #state ⇒ Object
Constructor Details
#initialize(options) ⇒ Push
Returns a new instance of Push.
38 39 40 41 42 |
# File 'lib/boxcar_publisher.rb', line 38 def initialize result = BoxcarPublisher._conn.post 'push', @id = result.body['ok'] @url = result.headers['Location'] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
36 37 38 |
# File 'lib/boxcar_publisher.rb', line 36 def id @id end |
#url ⇒ Object
Returns the value of attribute url.
36 37 38 |
# File 'lib/boxcar_publisher.rb', line 36 def url @url end |
Instance Method Details
#delete ⇒ Object
55 56 57 58 |
# File 'lib/boxcar_publisher.rb', line 55 def delete result = BoxcarPublisher._conn.delete "push/#{id}" raise "Expected repsonse to have HTTP status 202, received #{result.status}" unless result.status == 202 end |
#state ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/boxcar_publisher.rb', line 44 def state result = BoxcarPublisher._conn.get "push/#{id}" json = result.body {}.tap do |res| json.each do |key, value| value = (DateTime.parse(value).to_time rescue value) if key =~ /_at\z/ res[key.to_sym] = value end end end |