Sha256: 7d4871f4cf6981769534dc4810f7df5e3cacdcb1eb3e2307bfe9aff7fb64e452
Contents?: true
Size: 955 Bytes
Versions: 8
Compression:
Stored size: 955 Bytes
Contents
require "metamorpher/terms/term" require "metamorpher/matcher/match" require "metamorpher/matcher/no_match" module Metamorpher module Terms class Literal < Term attributes children: [] def initialize(attributes = {}) initialize_attributes(attributes) children.each { |child| child.parent = self } end def inspect if leaf? "#{name}" else "#{name}(#{children.map(&:inspect).join(', ')})" end end def leaf? children.empty? end def branch? !leaf? end def child_of?(parent_name) parent && parent.name == parent_name end def children_younger_than_or_equal_to(child) children[(index(child))..-1] end private def index(child) children.index(child) || fail(ArgumentError, "#{child.inspect} is not a child of #{inspect}") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems