Class: JsonProjection::Fifo
- Inherits:
-
Object
- Object
- JsonProjection::Fifo
- Defined in:
- lib/json-projection/parser/fifo.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #append(fifo) ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(stack = []) ⇒ Fifo
constructor
A new instance of Fifo.
- #pop ⇒ Object
- #push(val) ⇒ Object
Constructor Details
#initialize(stack = []) ⇒ Fifo
Returns a new instance of Fifo.
12 13 14 |
# File 'lib/json-projection/parser/fifo.rb', line 12 def initialize(stack = []) @stack = stack end |
Class Method Details
.empty ⇒ Object
4 5 6 |
# File 'lib/json-projection/parser/fifo.rb', line 4 def self.empty @empty ||= self.new end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 |
# File 'lib/json-projection/parser/fifo.rb', line 33 def ==(other) return false unless other.is_a?(Fifo) return stack == other.stack end |
#append(fifo) ⇒ Object
42 43 44 45 46 |
# File 'lib/json-projection/parser/fifo.rb', line 42 def append(fifo) return self if fifo.empty? return fifo if self.empty? Fifo.new(@stack.concat(fifo.stack)) end |
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/json-projection/parser/fifo.rb', line 29 def empty? @stack.empty? end |
#hash ⇒ Object
38 39 40 |
# File 'lib/json-projection/parser/fifo.rb', line 38 def hash stack.hash end |