Class: XRay::JS::Elements
- Inherits:
-
Node
- Object
- XRay::JS::Elements
show all
- Defined in:
- lib/js/struct.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(elements, position = nil) ⇒ Elements
35
36
37
38
|
# File 'lib/js/struct.rb', line 35
def initialize(elements, position = nil)
@elements, @position = elements, position
@type = 'elements'
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
49
50
51
|
# File 'lib/js/struct.rb', line 49
def method_missing(m, *args, &block)
@elements.send m, *args, &block
end
|
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
33
34
35
|
# File 'lib/js/struct.rb', line 33
def elements
@elements
end
|
#type ⇒ Object
Returns the value of attribute type.
33
34
35
|
# File 'lib/js/struct.rb', line 33
def type
@type
end
|
Instance Method Details
#contains?(target) ⇒ Boolean
Also known as:
contain?
53
54
55
|
# File 'lib/js/struct.rb', line 53
def contains?( target )
@elements.any? {|elm| elm.contains? target }
end
|
#position ⇒ Object
44
45
46
47
|
# File 'lib/js/struct.rb', line 44
def position
@position ? @position :
elements.empty? ? nil : elements[0].position
end
|
#text ⇒ Object
40
41
42
|
# File 'lib/js/struct.rb', line 40
def text
"[#{elements.collect(&:text).join(',')}]"
end
|