class Highway::Compiler::Analyze::Tree::Values::Base

This class is a base abstract class for other classes in this module. You should not use it directly.

Public Class Methods

new() click to toggle source

Initialize an instance.

# 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

Public Instance Methods

flatten_segments() click to toggle source

A flat array of all segments.

@return [Array<Highway::Compiler::Analyze::Tree::Segments::*>]

# 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) click to toggle source

A flat array of all segments which satisty the given block.

@param &block [Block] The selection block.

@return [Array<Highway::Compiler::Analyze::Tree::Segments::*>]

# File lib/highway/compiler/analyze/tree/values/base.rb, line 35
def select_segments(&block)
  flatten_segments.select(&block)
end
select_variable_segments(&block) click to toggle source

The flat array of variable segments which satisfy the given block.

@param &block [Block] The selection block.

@return [Array<Highway::Compiler::Analyze::Tree::Segments::Variable>]

# 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) click to toggle source

The flat array of variable segments with the given scope.

@param &block [Symbol] The lookup scope.

@return [Array<Highway::Compiler::Analyze::Tree::Segments::Variable>]

# 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