Class: RubyCop::Ruby::List

Inherits:
Node
  • Object
show all
Defined in:
lib/ruby_cop/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.



4
5
6
# File 'lib/ruby_cop/ruby/list.rb', line 4

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.



8
9
10
# File 'lib/ruby_cop/ruby/list.rb', line 8

def elements
  @elements
end

Instance Method Details

#add(element) ⇒ Object



10
11
12
# File 'lib/ruby_cop/ruby/list.rb', line 10

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