Class: Musa::GenerativeGrammar::Implementation::FinalNode Private

Inherits:
Node
  • Object
show all
Defined in:
lib/musa-dsl/generative/generative-grammar.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Terminal node with fixed content.

Represents a leaf node in the grammar tree with constant content.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, attributes) ⇒ FinalNode

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FinalNode.

Parameters:

  • content (Object)

    node content

  • attributes (Hash)

    node attributes



455
456
457
458
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 455

def initialize(content, attributes)
  super()
  @element = OptionElement.new(content, attributes)
end

Instance Attribute Details

#attributesHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

node attributes

Returns:

  • (Hash)

    the current value of attributes



448
449
450
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 448

def attributes
  @attributes
end

#contentObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

node content

Returns:

  • (Object)

    the current value of content



448
449
450
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 448

def content
  @content
end

Instance Method Details

#_options(parent: nil, &condition) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/musa-dsl/generative/generative-grammar.rb', line 461

def _options(parent: nil, &condition)
  parent ||= []

  if block_given?
    if yield(parent + [@element])
      [[@element]]
    else
      []
    end
  else
    [[@element]]
  end
end