Class: RT::RTCell

Inherits:
Object
  • Object
show all
Defined in:
lib/rt/rtparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, align = nil) ⇒ RTCell

Returns a new instance of RTCell.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rt/rtparser.rb', line 8

def initialize(value, align = nil)
  @rowspan = @colspan = 1
  @value = value
  @align = case align       # {:left, :center :right}
           when :left, :center, :right
             align
           when nil
             if /^[+\-]?[0-9]+\.?[0-9]*/ === value
               :right
             else
               :left
             end
           else
             raise "[BUG]Illegal align type"
           end
end

Instance Attribute Details

#alignObject (readonly)

Returns the value of attribute align.



50
51
52
# File 'lib/rt/rtparser.rb', line 50

def align
  @align
end

#colspanObject

Returns the value of attribute colspan.



51
52
53
# File 'lib/rt/rtparser.rb', line 51

def colspan
  @colspan
end

#rowspanObject

Returns the value of attribute rowspan.



51
52
53
# File 'lib/rt/rtparser.rb', line 51

def rowspan
  @rowspan
end

#valueObject (readonly)

Returns the value of attribute value.



50
51
52
# File 'lib/rt/rtparser.rb', line 50

def value
  @value
end

Instance Method Details

#==(x) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/rt/rtparser.rb', line 24

def == (x)
  case x
  when self.class
    self.value == "" && x.value == "" || self.value == x.value && self.align == x.align
  else
    false
  end
end

#inspectObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rt/rtparser.rb', line 32

def inspect
  if value==""
    "()"
  else
    a = case align
        when :left
          "l"
        when :center
          "c"
        when :right
          "r"
        else
          raise "[BUG]Illegal align type"
        end
    "#{a}(#{value})"
  end
end