Class: Spreet::Cell

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

Overview

Represents a cell in a sheet

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#annotationObject

Returns the value of attribute annotation.



10
11
12
# File 'lib/spreet/cell.rb', line 10

def annotation
  @annotation
end

#coordinatesObject (readonly)

Returns the value of attribute coordinates.



9
10
11
# File 'lib/spreet/cell.rb', line 9

def coordinates
  @coordinates
end

#sheetObject (readonly)

Returns the value of attribute sheet.



9
10
11
# File 'lib/spreet/cell.rb', line 9

def sheet
  @sheet
end

#textObject

Returns the value of attribute text.



9
10
11
# File 'lib/spreet/cell.rb', line 9

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/spreet/cell.rb', line 9

def type
  @type
end

#valueObject

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

Returns:

  • (Boolean)


40
41
42
# File 'lib/spreet/cell.rb', line 40

def covered?
  @covered
end

#empty?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/spreet/cell.rb', line 36

def empty?
  @empty
end

#inspectObject



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