Class: OperaWatir::Selector
- Includes:
- Deprecated
- Defined in:
- lib/operawatir/selector.rb,
lib/operawatir/compat/selector.rb
Defined Under Namespace
Classes: BlockBuilder
Constant Summary collapse
- BASE_TYPES =
[:id, :class_name, :tag_name, :css, :xpath, :name]
- COLLECTION_TYPES =
[:index, :attribute]
- META_TYPES =
[:join, :antijoin]
- TYPES =
BASE_TYPES + COLLECTION_TYPES + META_TYPES
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#sexp ⇒ Object
Returns the value of attribute sexp.
Instance Method Summary collapse
- #apply(fn, *args) ⇒ Object
- #eval(exp = sexp) ⇒ Object
-
#initialize(collection, sexp = nil) ⇒ Selector
constructor
A new instance of Selector.
Constructor Details
#initialize(collection, sexp = nil) ⇒ Selector
Returns a new instance of Selector.
10 11 12 |
# File 'lib/operawatir/selector.rb', line 10 def initialize(collection, sexp=nil) self.collection, self.sexp = collection, sexp end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
8 9 10 |
# File 'lib/operawatir/selector.rb', line 8 def collection @collection end |
#sexp ⇒ Object
Returns the value of attribute sexp.
8 9 10 |
# File 'lib/operawatir/selector.rb', line 8 def sexp @sexp end |
Instance Method Details
#apply(fn, *args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/operawatir/selector.rb', line 18 def apply(fn, *args) elms = args.shift # Say hello to the the ol' send trick. # # Private methods can be called when using send. This "bug" was # briefly disabled in 1.9 but people complained because it's very # handy (but bad). if elms.nil? collection.parent.send("find_elements_by_#{fn}", *args) else collection.send(:_elms=, elms) if META_TYPES.include?(fn) send("apply_#{fn}", elms, args) else collection.send("find_elements_by_#{fn}", *args) end end end |
#eval(exp = sexp) ⇒ Object
14 15 16 |
# File 'lib/operawatir/selector.rb', line 14 def eval(exp=sexp) exp.is_a?(Array) ? apply(*optimise(exp).map {|x| eval(x)}) : exp end |