Class: SK::Cell

Inherits:
Element show all
Defined in:
lib/table.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#el, #locator

Instance Method Summary collapse

Methods inherited from Element

#children, #displayed?, #enabled?, #exists?, #find, #find_child_el, #html, #parent_el, #search, #text

Constructor Details

#initialize(locator, index) ⇒ Cell

Returns a new instance of Cell.



7
8
9
10
# File 'lib/table.rb', line 7

def initialize(locator,index)
  super(locator) # creates the el and locator
  @index = index # remember your position
end

Instance Attribute Details

#indexObject (readonly)

row is an element that “remembers” it’s index in the row



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

def index
  @index
end

Instance Method Details

#as_numObject



12
13
14
15
16
# File 'lib/table.rb', line 12

def as_num
  # trace "cell = #{cell.text}"
  sign = self.text.include?('(') ? -1 : 1
  sign * self.text.gsub(/[$,()]/, '').to_f
end

#to_sObject



18
19
20
# File 'lib/table.rb', line 18

def to_s
  "<SK::Cell #{@index} [#{self.text}]>"
end