Class: StHtmlTable::Cell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, row) ⇒ Cell

Returns a new instance of Cell.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/st_html_table/cell.rb', line 16

def initialize(table, row)
  @text = ' '
  @row = row
  @table = table
  @is_header = false
  @cols = 1
  @col_id = 0
  @row_id = 0
  @type = :neutral
  @valign = :top

  @bold = false
  @italic = false
  @align = :left

  @ident = 6
end

Instance Attribute Details

#alignObject

Returns the value of attribute align.



12
13
14
# File 'lib/st_html_table/cell.rb', line 12

def align
  @align
end

#boldObject

Returns the value of attribute bold.



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

def bold
  @bold
end

#col_idObject

Returns the value of attribute col_id.



8
9
10
# File 'lib/st_html_table/cell.rb', line 8

def col_id
  @col_id
end

#colsObject

Returns the value of attribute cols.



7
8
9
# File 'lib/st_html_table/cell.rb', line 7

def cols
  @cols
end

#is_headerObject

Returns the value of attribute is_header.



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

def is_header
  @is_header
end

#italicObject

Returns the value of attribute italic.



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

def italic
  @italic
end

#rowObject (readonly)

Returns the value of attribute row.



4
5
6
# File 'lib/st_html_table/cell.rb', line 4

def row
  @row
end

#row_idObject

Returns the value of attribute row_id.



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

def row_id
  @row_id
end

#tableObject (readonly)

Returns the value of attribute table.



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

def table
  @table
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#typeObject

Returns the value of attribute type.



14
15
16
# File 'lib/st_html_table/cell.rb', line 14

def type
  @type
end

#valignObject

Returns the value of attribute valign.



13
14
15
# File 'lib/st_html_table/cell.rb', line 13

def valign
  @valign
end

Instance Method Details

#prefix=(value) ⇒ Object



34
35
36
# File 'lib/st_html_table/cell.rb', line 34

def prefix=(value)
  @prefix = value
end

#suffix=(value) ⇒ Object



38
39
40
# File 'lib/st_html_table/cell.rb', line 38

def suffix=(value)
  @suffix = value
end

#to_htmlObject



46
47
48
49
50
51
52
53
54
# File 'lib/st_html_table/cell.rb', line 46

def to_html
  type = @is_header ? 'th' : 'td'

  out = Array.new
  out << (' ' * @ident) + build_cell_arguments(type)
  out << (' ' * (@ident + 2)) + @text.to_s
  out << (' ' * @ident) + "</#{type}>"
  out.join("\n")
end

#to_sObject



42
43
44
# File 'lib/st_html_table/cell.rb', line 42

def to_s
  @text.gsub(%r{</?[^>]+?>}, '')
end