Class: Rubycop::Analyzer::Ruby::List

Inherits:
Node
  • Object
show all
Defined in:
lib/rubycop/analyzer/ruby/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#accept

Constructor Details

#initialize(elements = nil) ⇒ List

Returns a new instance of List.



5
6
7
# File 'lib/rubycop/analyzer/ruby/list.rb', line 5

def initialize(elements=nil)
  @elements = Array(elements).compact # TODO: compact might cause problems here
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



9
10
11
# File 'lib/rubycop/analyzer/ruby/list.rb', line 9

def elements
  @elements
end

Instance Method Details

#add(element) ⇒ Object



11
12
13
# File 'lib/rubycop/analyzer/ruby/list.rb', line 11

def add(element)
  @elements.push(element)
end