Class: BELParser::Script::Filter

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

Overview

Filter will enumerate AST nodes that are relevant to lines in a BEL Script document. It selects the relevant nodes from an AST node enumerator.

Constant Summary collapse

TYPES =

Represents the BEL Script AST Node type. TODO These could be AST::Node subclasses instead.

[
  :simple_statement,
  :observed_term,
  :nested_statement,
  :annotation_definition,
  :namespace_definition,
  :set,
  :document_property,
  :unset,
  :blank_line,
  :comment_line
]

Instance Method Summary collapse

Constructor Details

#initialize(ast_enum) ⇒ Filter

Returns a new instance of Filter.



22
23
24
# File 'lib/bel_parser/script/filter.rb', line 22

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

Instance Method Details

#each(&block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/bel_parser/script/filter.rb', line 26

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