Class: Apnotic::Push
- Inherits:
-
Object
- Object
- Apnotic::Push
- Defined in:
- lib/apnotic/push.rb
Instance Attribute Summary collapse
-
#http2_request ⇒ Object
readonly
Returns the value of attribute http2_request.
Instance Method Summary collapse
- #emit(event, arg) ⇒ Object
-
#initialize(http2_request) ⇒ Push
constructor
A new instance of Push.
- #on(event, &block) ⇒ Object
Constructor Details
#initialize(http2_request) ⇒ Push
Returns a new instance of Push.
6 7 8 9 10 11 12 13 |
# File 'lib/apnotic/push.rb', line 6 def initialize(http2_request) @http2_request = http2_request @headers = {} @data = '' @events = {} listen_for_http2_events end |
Instance Attribute Details
#http2_request ⇒ Object (readonly)
Returns the value of attribute http2_request.
4 5 6 |
# File 'lib/apnotic/push.rb', line 4 def http2_request @http2_request end |
Instance Method Details
#emit(event, arg) ⇒ Object
22 23 24 25 |
# File 'lib/apnotic/push.rb', line 22 def emit(event, arg) return unless @events[event] @events[event].each { |b| b.call(arg) } end |
#on(event, &block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/apnotic/push.rb', line 15 def on(event, &block) raise ArgumentError, 'on event must provide a block' unless block_given? @events[event] ||= [] @events[event] << block end |