Class: BELParser::Expression::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/bel_parser/expression/filter.rb

Overview

Filter will enumerate AST nodes that make up BEL expressions. It selects the relevant nodes from an AST node enumerator.

Constant Summary collapse

TYPES =

Represents BEL expression node types.

[
  :simple_statement,
  :observed_term,
  :nested_statement,
  :term,
  :parameter
]

Instance Method Summary collapse

Constructor Details

#initialize(ast_enum) ⇒ Filter

Returns a new instance of Filter.



18
19
20
# File 'lib/bel_parser/expression/filter.rb', line 18

def initialize(ast_enum)
  @ast_filter = BELParser::ASTFilter.new(ast_enum, *TYPES)
end

Instance Method Details

#each(&block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/bel_parser/expression/filter.rb', line 22

def each(&block)
  if block_given?
    @ast_filter.each(&block)
  else
    enum_for(:each)
  end
end