Class: Synthra::Parser::AST::EnumValueNode

Inherits:
Node
  • Object
show all
Defined in:
lib/synthra/parser/ast.rb

Overview

Enum value with optional probability

Represents a single value within an enum type, optionally with a probability weight.

Examples:

DSL

status: enum(pending, active:60%, completed:30%)

AST

EnumValueNode.new(value: "pending")
EnumValueNode.new(value: "active", probability: 60)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, probability: nil, line: nil) ⇒ EnumValueNode

Create a new EnumValueNode

Parameters:

  • value (String)

    enum value

  • probability (Integer, nil) (defaults to: nil)

    probability percentage

  • line (Integer, nil) (defaults to: nil)

    source line number



603
604
605
606
607
# File 'lib/synthra/parser/ast.rb', line 603

def initialize(value:, probability: nil, line: nil)
  super(line: line)
  @value = value
  @probability = probability
end

Instance Attribute Details

#probabilityObject (readonly)

Returns the value of attribute probability.



594
595
596
# File 'lib/synthra/parser/ast.rb', line 594

def probability
  @probability
end

#valueObject (readonly)

Returns the value of attribute value.



588
589
590
# File 'lib/synthra/parser/ast.rb', line 588

def value
  @value
end