Class: Fdlint::Parser::JS::Elements

Inherits:
Node
  • Object
show all
Defined in:
lib/fdlint/parser/js/struct.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#elementsObject (readonly)

Returns the value of attribute elements.



37
38
39
# File 'lib/fdlint/parser/js/struct.rb', line 37

def elements
  @elements
end

#typeObject (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?

Returns:

  • (Boolean)


57
58
59
# File 'lib/fdlint/parser/js/struct.rb', line 57

def contains?( target )
  @elements.any? {|elm| elm.contains? target }
end

#positionObject



48
49
50
51
# File 'lib/fdlint/parser/js/struct.rb', line 48

def position
  @position ? @position : 
     elements.empty? ? nil : elements[0].position
end

#textObject



44
45
46
# File 'lib/fdlint/parser/js/struct.rb', line 44

def text
  "[#{elements.collect(&:text).join(',')}]"
end