Class: Foxtail::Syntax::Parser::AST::Resource
- Inherits:
-
SyntaxNode
- Object
- BaseNode
- SyntaxNode
- Foxtail::Syntax::Parser::AST::Resource
- Defined in:
- lib/foxtail/syntax/parser/ast/resource.rb
Overview
Represents a Fluent resource containing messages, terms, and comments This is the root node of a parsed Fluent file
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
Attributes inherited from SyntaxNode
Attributes inherited from BaseNode
Instance Method Summary collapse
- #children ⇒ Object
-
#each_entry {|Message, Term| ... } ⇒ Enumerator, self
Iterate over Message and Term entries (excludes comments and junk).
-
#each_message {|Message| ... } ⇒ Enumerator, self
Iterate over Message entries only.
-
#each_term {|Term| ... } ⇒ Enumerator, self
Iterate over Term entries only.
-
#initialize(body = []) ⇒ Resource
constructor
A new instance of Resource.
Methods inherited from SyntaxNode
Methods inherited from BaseNode
Constructor Details
#initialize(body = []) ⇒ Resource
Returns a new instance of Resource.
12 13 14 15 |
# File 'lib/foxtail/syntax/parser/ast/resource.rb', line 12 def initialize(body=[]) super() @body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'lib/foxtail/syntax/parser/ast/resource.rb', line 10 def body @body end |
Instance Method Details
#children ⇒ Object
17 |
# File 'lib/foxtail/syntax/parser/ast/resource.rb', line 17 def children = body |
#each_entry {|Message, Term| ... } ⇒ Enumerator, self
Iterate over Message and Term entries (excludes comments and junk)
45 46 47 48 49 50 |
# File 'lib/foxtail/syntax/parser/ast/resource.rb', line 45 def each_entry(&block) return enum_for(__method__) unless block body.each {|entry| yield(entry) if entry.is_a?(Message) || entry.is_a?(Term) } self end |
#each_message {|Message| ... } ⇒ Enumerator, self
Iterate over Message entries only
23 24 25 26 27 28 |
# File 'lib/foxtail/syntax/parser/ast/resource.rb', line 23 def (&block) return enum_for(__method__) unless block body.each {|entry| yield(entry) if entry.is_a?(Message) } self end |
#each_term {|Term| ... } ⇒ Enumerator, self
Iterate over Term entries only
34 35 36 37 38 39 |
# File 'lib/foxtail/syntax/parser/ast/resource.rb', line 34 def each_term(&block) return enum_for(__method__) unless block body.each {|entry| yield(entry) if entry.is_a?(Term) } self end |