Class: ExcelAbstraction::CellRange

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/excel_templating/excel_abstraction/cell_range.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCellRange

Returns a new instance of CellRange.



8
9
10
# File 'lib/excel_templating/excel_abstraction/cell_range.rb', line 8

def initialize
  @cell_references = []
end

Instance Attribute Details

#cell_referencesObject (readonly, protected)

Returns the value of attribute cell_references.



24
25
26
# File 'lib/excel_templating/excel_abstraction/cell_range.rb', line 24

def cell_references
  @cell_references
end

Instance Method Details

#<<(attrs) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/excel_templating/excel_abstraction/cell_range.rb', line 16

def <<(attrs)
  cell_reference = ExcelAbstraction::CellReference.new(attrs)
  raise(ArgumentError, "Must be a CellReference belonging to the same row") if last && last.row != cell_reference.row
  self.cell_references << cell_reference
end

#each(&block) ⇒ Object



12
13
14
# File 'lib/excel_templating/excel_abstraction/cell_range.rb', line 12

def each(&block)
  cell_references.each { |cell_reference| yield(cell_reference) }
end