Class: Bolide::Q
- Inherits:
-
Object
- Object
- Bolide::Q
- Defined in:
- lib/bolide/q.rb
Instance Attribute Summary collapse
-
#bolide ⇒ Object
Returns the value of attribute bolide.
-
#expire_on ⇒ Object
Returns the value of attribute expire_on.
-
#msg_count ⇒ Object
Returns the value of attribute msg_count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(bolide, name) ⇒ Q
constructor
A new instance of Q.
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
- #new_token ⇒ Object
- #send_msg(body) ⇒ Object
Constructor Details
#initialize(bolide, name) ⇒ Q
Returns a new instance of Q.
8 9 10 11 12 13 14 |
# File 'lib/bolide/q.rb', line 8 def initialize(bolide, name) @bolide = bolide @name = name @token = nil @expire_on = nil @msg_count = nil end |
Instance Attribute Details
#bolide ⇒ Object
Returns the value of attribute bolide.
6 7 8 |
# File 'lib/bolide/q.rb', line 6 def bolide @bolide end |
#expire_on ⇒ Object
Returns the value of attribute expire_on.
6 7 8 |
# File 'lib/bolide/q.rb', line 6 def expire_on @expire_on end |
#msg_count ⇒ Object
Returns the value of attribute msg_count.
6 7 8 |
# File 'lib/bolide/q.rb', line 6 def msg_count @msg_count end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/bolide/q.rb', line 6 def name @name end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/bolide/q.rb', line 6 def token @token end |
Instance Method Details
#expired? ⇒ Boolean
16 17 18 19 20 21 22 23 24 |
# File 'lib/bolide/q.rb', line 16 def expired? resp = bolide.session.get('/q/' + name + '.xml', bolide.headers) if resp.status < 400 read_response resp else raise read_error(resp) end @expire_on && @expire_on > DateTime.now && @token end |
#marshal_dump ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/bolide/q.rb', line 40 def marshal_dump { :name=>@name, :token=>@token, :bolide=>@bolide, :msg_count=>@msg_count, :expire_on=>@expire_on } end |
#marshal_load(data) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/bolide/q.rb', line 50 def marshal_load(data) @name = data[:name] @bolide = data[:bolide] @msg_count = data[:msg_count] @token = data[:token] @expire_on = data[:expire_on] end |
#new_token ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/bolide/q.rb', line 26 def new_token resp = bolide.session.put('/q/' + name + '.xml','', bolide.headers) if resp.status < 400 read_response resp else raise read_error(resp) end return @token end |
#send_msg(body) ⇒ Object
36 37 38 |
# File 'lib/bolide/q.rb', line 36 def send_msg(body) bolide.send_msg(body, [@name]) end |