Class: Fdlint::Parser::JS::Elements
- Defined in:
- lib/fdlint/parser/js/struct.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #contains?(target) ⇒ Boolean (also: #contain?)
-
#initialize(elements, position = nil) ⇒ Elements
constructor
A new instance of Elements.
- #method_missing(m, *args, &block) ⇒ Object
- #position ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(elements, position = nil) ⇒ Elements
Returns a new instance of Elements.
39 40 41 42 |
# File 'lib/fdlint/parser/js/struct.rb', line 39 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
53 54 55 |
# File 'lib/fdlint/parser/js/struct.rb', line 53 def method_missing(m, *args, &block) @elements.send m, *args, &block end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
37 38 39 |
# File 'lib/fdlint/parser/js/struct.rb', line 37 def elements @elements end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
37 38 39 |
# File 'lib/fdlint/parser/js/struct.rb', line 37 def type @type end |
Instance Method Details
#contains?(target) ⇒ Boolean Also known as: contain?
57 58 59 |
# File 'lib/fdlint/parser/js/struct.rb', line 57 def contains?( target ) @elements.any? {|elm| elm.contains? target } end |
#position ⇒ Object
48 49 50 51 |
# File 'lib/fdlint/parser/js/struct.rb', line 48 def position @position ? @position : elements.empty? ? nil : elements[0].position end |
#text ⇒ Object
44 45 46 |
# File 'lib/fdlint/parser/js/struct.rb', line 44 def text "[#{elements.collect(&:text).join(',')}]" end |