Class: ExcelAbstraction::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/excel_templating/excel_abstraction/cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Cell

Returns a new instance of Cell.



5
6
7
8
9
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 5

def initialize(attrs = {})
  @position = Integer(attrs.fetch(:position) { raise ArgumentError.new("Position absent for ExcelAbstraction cell") })
  @val = attrs.fetch(:val) { raise ArgumentError.new("Value absent for ExcelAbstraction cell") }
  @styles = attrs.fetch(:styles) { {} }
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



3
4
5
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 3

def position
  @position
end

#stylesObject (readonly)

Returns the value of attribute styles.



3
4
5
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 3

def styles
  @styles
end

#valObject (readonly)

Returns the value of attribute val.



3
4
5
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 3

def val
  @val
end

Instance Method Details

#<=>(other) ⇒ Object



11
12
13
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 11

def <=>(other)
  position <=> other.position
end

#==(other) ⇒ Object



15
16
17
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 15

def ==(other)
  position == other.position && val == other.val && styles == other.styles
end

#to_cellObject



19
20
21
# File 'lib/excel_templating/excel_abstraction/cell.rb', line 19

def to_cell
  self
end