class Metamorpher::Terms::Literal
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 10 def initialize(attributes = {}) initialize_attributes(attributes) children.each { |child| child.parent = self } end
Public Instance Methods
branch?()
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 27 def branch? !leaf? end
child_of?(parent_name)
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 31 def child_of?(parent_name) parent && parent.name == parent_name end
children_younger_than_or_equal_to(child)
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 35 def children_younger_than_or_equal_to(child) children[(index(child))..-1] end
inspect()
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 15 def inspect if leaf? "#{name}" else "#{name}(#{children.map(&:inspect).join(', ')})" end end
leaf?()
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 23 def leaf? children.empty? end
Private Instance Methods
index(child)
click to toggle source
# File lib/metamorpher/terms/literal.rb, line 41 def index(child) children.index(child) || fail(ArgumentError, "#{child.inspect} is not a child of #{inspect}") end