Class: Watirmark::RadioMap
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ RadioMap
constructor
A new instance of RadioMap.
- #lookup(x) ⇒ Object
- #values(*args) ⇒ Object (also: #value)
Constructor Details
#initialize(hash = {}) ⇒ RadioMap
Returns a new instance of RadioMap.
20 21 22 23 24 25 |
# File 'lib/watirmark/page/radio_maps.rb', line 20 def initialize hash={} @maps = [] hash.each_pair do |key, val| values(key).maps_to(val) end end |
Instance Method Details
#lookup(x) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/watirmark/page/radio_maps.rb', line 35 def lookup(x) return nil if x.nil? @maps.each do |map| if Array === map.list map.list.each do |items| [*items].each do |item| return map.value if item.matches x end end else return map.value if map.list.matches x end end raise Watirmark::TestError, "No map value exists for '#{x}'" unless x x end |
#values(*args) ⇒ Object Also known as: value
27 28 29 30 31 |
# File 'lib/watirmark/page/radio_maps.rb', line 27 def values(*args) element = RadioMapElement.new(*args) @maps << element element end |