Class: PatternMatching::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/patternmatching/pattern.rb

Overview

Class for structured data/patterns

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, children) ⇒ Node

Returns a new instance of Node.



101
102
103
104
# File 'lib/patternmatching/pattern.rb', line 101

def initialize(name, children)
  @name = name
  @children = children
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



105
106
107
# File 'lib/patternmatching/pattern.rb', line 105

def name
  @name
end

Instance Method Details

#[](index) ⇒ Object



106
107
108
# File 'lib/patternmatching/pattern.rb', line 106

def [](index)
  @children[index]
end

#sizeObject



109
110
111
# File 'lib/patternmatching/pattern.rb', line 109

def size
  @children.size
end