Class: Arknmax::Reader
- Inherits:
-
Object
- Object
- Arknmax::Reader
- Defined in:
- lib/arknmax/reader.rb
Overview
:nodoc:
Constant Summary collapse
- DIGIT =
/\d/
- DIGIT_LINE =
/\d+/
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#max_digits_line ⇒ Object
readonly
Returns the value of attribute max_digits_line.
-
#size_limit ⇒ Object
readonly
Returns the value of attribute size_limit.
Instance Method Summary collapse
-
#initialize(size_limit, io: STDIN, max_digits_line: 1000) ⇒ Reader
constructor
A new instance of Reader.
- #perform ⇒ Object
Constructor Details
#initialize(size_limit, io: STDIN, max_digits_line: 1000) ⇒ Reader
Returns a new instance of Reader.
12 13 14 15 16 17 |
# File 'lib/arknmax/reader.rb', line 12 def initialize(size_limit, io: STDIN, max_digits_line: 1000) @size_limit = size_limit @io = io @max_digits_line = max_digits_line @container = Arknmax::Heap.new(size_limit) end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
10 11 12 |
# File 'lib/arknmax/reader.rb', line 10 def container @container end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
9 10 11 |
# File 'lib/arknmax/reader.rb', line 9 def io @io end |
#max_digits_line ⇒ Object (readonly)
Returns the value of attribute max_digits_line.
9 10 11 |
# File 'lib/arknmax/reader.rb', line 9 def max_digits_line @max_digits_line end |
#size_limit ⇒ Object (readonly)
Returns the value of attribute size_limit.
9 10 11 |
# File 'lib/arknmax/reader.rb', line 9 def size_limit @size_limit end |
Instance Method Details
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/arknmax/reader.rb', line 19 def perform while (line = io.read(max_digits_line)) finish_digits_line!(line) if end_with_num_char?(line) line.scan(DIGIT_LINE) { |n| container << n.to_i } end container end |