Class: Astel::NodePattern::PredicateCompiler
- Inherits:
-
Object
- Object
- Astel::NodePattern::PredicateCompiler
- Defined in:
- lib/astel/node_pattern/predicate_compiler.rb
Constant Summary collapse
- NODE_CLASSES =
Prism.constants.filter_map do |constant| value = Prism.const_get(constant) next unless value.is_a?(Class) && value < Prism::Node type = NodeType.from_class_name(constant.to_s) [type, value] rescue NameError nil end.to_h.freeze
Instance Method Summary collapse
Instance Method Details
#compile(pattern) ⇒ Object
16 17 18 19 20 |
# File 'lib/astel/node_pattern/predicate_compiler.rb', line 16 def compile(pattern) @variable = 0 expression = expression_for(pattern, 'value') eval("->(value) { #{expression} }", binding, __FILE__, __LINE__) end |