Class: Haecksler::Sheet
- Inherits:
-
Object
- Object
- Haecksler::Sheet
- Includes:
- Enumerable
- Defined in:
- lib/haecksler/sheet.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ header: false, footer: false, header_check: proc{ false }, footer_check: proc{ false } }
Instance Attribute Summary collapse
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(input, options = {}) ⇒ Sheet
constructor
A new instance of Sheet.
Constructor Details
#initialize(input, options = {}) ⇒ Sheet
Returns a new instance of Sheet.
9 10 11 12 13 14 15 16 17 |
# File 'lib/haecksler/sheet.rb', line 9 def initialize(input, ={}) = DEFAULT_OPTIONS.merge() @header = [:header] @footer = [:footer] @row = [:row] @input = input @header_check = [:header_check] @footer_check = [:footer_check] end |
Instance Attribute Details
#row ⇒ Object (readonly)
Returns the value of attribute row.
5 6 7 |
# File 'lib/haecksler/sheet.rb', line 5 def row @row end |
Instance Method Details
#each ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/haecksler/sheet.rb', line 19 def each @input.lazy.each do |input| if @header_check.call(input) yield @header.parse(input.chomp) elsif @footer_check.call(input) yield @footer.parse(input.chomp) else yield @row.parse(input.chomp) end end end |