Class: Claus::AST::List

Inherits:
Node
  • Object
show all
Defined in:
lib/claus.rb

Overview

Hash

Instance Attribute Summary

Attributes inherited from Node

#ast

Instance Method Summary collapse

Methods inherited from Node

#initialize

Constructor Details

This class inherits a constructor from Claus::AST::Node

Instance Method Details

#compile(expression) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/claus.rb', line 78

def compile expression
  expression.map do |v|
    case v
      when ::Hash     then Hash.new(v)
      when ::Array    then List.new(v)
      when ::Range    then List.new(v)
      when Claus      then v.ast
      else            v.kind_of?(Node) ? v : Node.new(v)
    end
  end
end

#match?(value) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/claus.rb', line 90

def match? value
  !!ast.find {|node| node.match?(value)}
end