Class: Highway::Compiler::Analyze::Tree::Values::Base
- Inherits:
-
Object
- Object
- Highway::Compiler::Analyze::Tree::Values::Base
- Defined in:
- lib/highway/compiler/analyze/tree/values/base.rb
Overview
This class is a base abstract class for other classes in this module. You should not use it directly.
Instance Method Summary collapse
-
#flatten_segments ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::*>
A flat array of all segments.
-
#initialize ⇒ Base
constructor
Initialize an instance.
-
#select_segments(&block) ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::*>
A flat array of all segments which satisty the given block.
-
#select_variable_segments(&block) ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::Variable>
The flat array of variable segments which satisfy the given block.
-
#select_variable_segments_with_scope(scope) ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::Variable>
The flat array of variable segments with the given scope.
Constructor Details
#initialize ⇒ Base
Initialize an instance.
19 20 21 |
# File 'lib/highway/compiler/analyze/tree/values/base.rb', line 19 def initialize() raise NotImplementedError.new("You must not call `#{__method__.to_s}` on `#{self.class.to_s}`.") end |
Instance Method Details
#flatten_segments ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::*>
A flat array of all segments.
26 27 28 |
# File 'lib/highway/compiler/analyze/tree/values/base.rb', line 26 def flatten_segments raise NotImplementedError.new("You must override `#{__method__.to_s}` in `#{self.class.to_s}`.") end |
#select_segments(&block) ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::*>
A flat array of all segments which satisty the given block.
35 36 37 |
# File 'lib/highway/compiler/analyze/tree/values/base.rb', line 35 def select_segments(&block) flatten_segments.select(&block) end |
#select_variable_segments(&block) ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::Variable>
The flat array of variable segments which satisfy the given block.
44 45 46 47 48 49 50 |
# File 'lib/highway/compiler/analyze/tree/values/base.rb', line 44 def select_variable_segments(&block) if block_given? select_segments { |s| s.is_a?(Segments::Variable) && block.call(s) } else select_segments { |s| s.is_a?(Segments::Variable) } end end |
#select_variable_segments_with_scope(scope) ⇒ Array<Highway::Compiler::Analyze::Tree::Segments::Variable>
The flat array of variable segments with the given scope.
57 58 59 |
# File 'lib/highway/compiler/analyze/tree/values/base.rb', line 57 def select_variable_segments_with_scope(scope) select_variable_segments { |s| s.scope == scope } end |