Class: ExcelWalker::Writer::Hook
- Inherits:
-
Object
- Object
- ExcelWalker::Writer::Hook
- Defined in:
- lib/excel_walker/writer/hook.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
- #after_column(offset) ⇒ Object
- #fill(&block) ⇒ Object
-
#initialize(condition) ⇒ Hook
constructor
A new instance of Hook.
- #match?(row_num) ⇒ Boolean
- #run(row_num) ⇒ Object
Constructor Details
#initialize(condition) ⇒ Hook
Returns a new instance of Hook.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/excel_walker/writer/hook.rb', line 8 def initialize(condition) @matcher = case true when condition.is_a?(Range), condition.is_a?(Array) @max = condition.max proc { |row_num| condition.include?(row_num) } when condition.is_a?(Fixnum) @max = condition proc { |row_num| condition === row_num } else raise ArgumentError.new('Can only take Range, Integers or Arrays') end @row_index = 0 end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
5 6 7 |
# File 'lib/excel_walker/writer/hook.rb', line 5 def max @max end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/excel_walker/writer/hook.rb', line 5 def offset @offset end |
#style ⇒ Object
Returns the value of attribute style.
6 7 8 |
# File 'lib/excel_walker/writer/hook.rb', line 6 def style @style end |
Instance Method Details
#after_column(offset) ⇒ Object
26 27 28 29 |
# File 'lib/excel_walker/writer/hook.rb', line 26 def after_column(offset) @offset = offset self end |
#fill(&block) ⇒ Object
31 32 33 |
# File 'lib/excel_walker/writer/hook.rb', line 31 def fill(&block) @filler = block end |
#match?(row_num) ⇒ Boolean
22 23 24 |
# File 'lib/excel_walker/writer/hook.rb', line 22 def match?(row_num) @matcher[row_num] end |