Class: Utils::StdinSimulator
- Inherits:
-
Object
- Object
- Utils::StdinSimulator
- Defined in:
- lib/utils.rb
Overview
Standard input simulator
Instance Attribute Summary collapse
-
#input_queue ⇒ Object
readonly
Returns the value of attribute input_queue.
Instance Method Summary collapse
- #<<(input) ⇒ Object
- #gets ⇒ Object
-
#initialize ⇒ StdinSimulator
constructor
A new instance of StdinSimulator.
Constructor Details
#initialize ⇒ StdinSimulator
Returns a new instance of StdinSimulator.
6 7 8 9 |
# File 'lib/utils.rb', line 6 def initialize # Represent an input queue as an array @input_queue = [] end |
Instance Attribute Details
#input_queue ⇒ Object (readonly)
Returns the value of attribute input_queue.
4 5 6 |
# File 'lib/utils.rb', line 4 def input_queue @input_queue end |
Instance Method Details
#<<(input) ⇒ Object
11 12 13 14 |
# File 'lib/utils.rb', line 11 def <<(input) # Add an element to the input queue @input_queue << input end |
#gets ⇒ Object
16 17 18 19 |
# File 'lib/utils.rb', line 16 def gets # Dequeue the first element in the queue @input_queue.shift end |