Class: WebSocket::Extensions::Offers
- Inherits:
-
Object
- Object
- WebSocket::Extensions::Offers
- Defined in:
- lib/websocket/extensions/parser.rb
Instance Method Summary collapse
- #by_name(name) ⇒ Object
- #each_offer(&block) ⇒ Object
-
#initialize ⇒ Offers
constructor
A new instance of Offers.
- #push(name, params) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ Offers
Returns a new instance of Offers.
84 85 86 87 |
# File 'lib/websocket/extensions/parser.rb', line 84 def initialize @by_name = {} @in_order = [] end |
Instance Method Details
#by_name(name) ⇒ Object
101 102 103 |
# File 'lib/websocket/extensions/parser.rb', line 101 def by_name(name) @by_name[name] || [] end |
#each_offer(&block) ⇒ Object
95 96 97 98 99 |
# File 'lib/websocket/extensions/parser.rb', line 95 def each_offer(&block) @in_order.each do |offer| block.call(offer[:name], offer[:params]) end end |
#push(name, params) ⇒ Object
89 90 91 92 93 |
# File 'lib/websocket/extensions/parser.rb', line 89 def push(name, params) @by_name[name] ||= [] @by_name[name].push(params) @in_order.push(:name => name, :params => params) end |
#to_a ⇒ Object
105 106 107 |
# File 'lib/websocket/extensions/parser.rb', line 105 def to_a @in_order.dup end |