Class: Spreet::Cell
- Inherits:
-
Object
- Object
- Spreet::Cell
- Defined in:
- lib/spreet/cell.rb
Overview
Represents a cell in a sheet
Instance Attribute Summary collapse
-
#annotation ⇒ Object
Returns the value of attribute annotation.
-
#coordinates ⇒ Object
readonly
Returns the value of attribute coordinates.
-
#sheet ⇒ Object
readonly
Returns the value of attribute sheet.
-
#text ⇒ Object
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other_cell) ⇒ Object
- #clear! ⇒ Object
- #covered? ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(sheet, *args) ⇒ Cell
constructor
A new instance of Cell.
- #inspect ⇒ Object
- #remove! ⇒ Object
Constructor Details
#initialize(sheet, *args) ⇒ Cell
Returns a new instance of Cell.
12 13 14 15 16 17 18 19 |
# File 'lib/spreet/cell.rb', line 12 def initialize(sheet, *args) @sheet = sheet @coordinates = Coordinates.new(*args) self.value = nil @empty = true @covered = false # determine_covered @annotation = nil end |
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
10 11 12 |
# File 'lib/spreet/cell.rb', line 10 def annotation @annotation end |
#coordinates ⇒ Object (readonly)
Returns the value of attribute coordinates.
9 10 11 |
# File 'lib/spreet/cell.rb', line 9 def coordinates @coordinates end |
#sheet ⇒ Object (readonly)
Returns the value of attribute sheet.
9 10 11 |
# File 'lib/spreet/cell.rb', line 9 def sheet @sheet end |
#text ⇒ Object
Returns the value of attribute text.
9 10 11 |
# File 'lib/spreet/cell.rb', line 9 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/spreet/cell.rb', line 9 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
9 10 11 |
# File 'lib/spreet/cell.rb', line 9 def value @value end |
Instance Method Details
#<=>(other_cell) ⇒ Object
53 54 55 |
# File 'lib/spreet/cell.rb', line 53 def <=>(other_cell) self.coordinates <=> other_cell.coordinates end |
#clear! ⇒ Object
44 45 46 47 |
# File 'lib/spreet/cell.rb', line 44 def clear! self.value = nil @empty = true end |
#covered? ⇒ Boolean
40 41 42 |
# File 'lib/spreet/cell.rb', line 40 def covered? @covered end |
#empty? ⇒ Boolean
36 37 38 |
# File 'lib/spreet/cell.rb', line 36 def empty? @empty end |
#inspect ⇒ Object
61 62 63 |
# File 'lib/spreet/cell.rb', line 61 def inspect "<#{self.coordinates}: #{self.text.inspect}#{'('+self.value.inspect+')' if self.text != self.value}>" end |
#remove! ⇒ Object
49 50 51 |
# File 'lib/spreet/cell.rb', line 49 def remove! @sheet.remove(self.coordinates) end |