Class: TinyTable::Cell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, alignment) ⇒ Cell

Returns a new instance of Cell.



5
6
7
8
# File 'lib/tinytable/cell.rb', line 5

def initialize(text, alignment)
  @text = text || ''
  @alignment = alignment
end

Instance Attribute Details

#alignmentObject (readonly)

Returns the value of attribute alignment.



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

def alignment
  @alignment
end

Instance Method Details

#==(obj) ⇒ Object



10
11
12
13
14
# File 'lib/tinytable/cell.rb', line 10

def ==(obj)
  return false unless obj.is_a? Cell
  text == obj.text &&
    alignment == obj.alignment
end

#textObject



16
17
18
# File 'lib/tinytable/cell.rb', line 16

def text
  @text.to_s
end

#widthObject



20
21
22
# File 'lib/tinytable/cell.rb', line 20

def width
  text.length
end