class Spreet::Cell
Represents a cell in a sheet
Attributes
annotation[RW]
coordinates[R]
sheet[R]
text[R]
type[R]
value[R]
Public Class Methods
new(sheet, *args)
click to toggle source
# 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
Public Instance Methods
<=>(other_cell)
click to toggle source
# File lib/spreet/cell.rb, line 53 def <=>(other_cell) self.coordinates <=> other_cell.coordinates end
clear!()
click to toggle source
# File lib/spreet/cell.rb, line 44 def clear! self.value = nil @empty = true end
covered?()
click to toggle source
# File lib/spreet/cell.rb, line 40 def covered? @covered end
empty?()
click to toggle source
# File lib/spreet/cell.rb, line 36 def empty? @empty end
inspect()
click to toggle source
# File lib/spreet/cell.rb, line 61 def inspect "<#{self.coordinates}: #{self.text.inspect}#{'('+self.value.inspect+')' if self.text != self.value}>" end
remove!()
click to toggle source
# File lib/spreet/cell.rb, line 49 def remove! @sheet.remove(self.coordinates) end
text=(val)
click to toggle source
# File lib/spreet/cell.rb, line 57 def text=(val) @text = val.to_s end
value=(val)
click to toggle source
# File lib/spreet/cell.rb, line 21 def value=(val) if val.is_a?(Cell) @value = val.value @type = val.type self.text = val.text @empty = val.empty? @annotation = val.annotation else @value = val @type = determine_type self.text = val @empty = false end end
Private Instance Methods
determine_type()
click to toggle source
# File lib/spreet/cell.rb, line 68 def determine_type if value.is_a? Date or value.is_a? DateTime :date elsif value.is_a? Numeric # or percentage :float elsif value.is_a? Money :currency elsif value.is_a? Duration :time elsif value.is_a?(TrueClass) or value.is_a?(FalseClass) :boolean else # if value.is_a?(String) :string end end