Class: Synthra::Parser::AST::ScenarioNode
- Defined in:
- lib/synthra/parser/ast.rb
Overview
Scenario node
Represents a response scenario within an API definition. Scenarios define possible HTTP responses with status codes, probabilities, and response body shapes.
Instance Attribute Summary collapse
-
#directives ⇒ Object
readonly
Returns the value of attribute directives.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#response_fields ⇒ Object
readonly
Returns the value of attribute response_fields.
Instance Method Summary collapse
-
#initialize(name:, directives: [], response_fields: [], line: nil) ⇒ ScenarioNode
constructor
Create a new ScenarioNode.
-
#probability ⇒ Integer?
Get the probability from directives.
-
#status_code ⇒ Integer?
Get the status code from directives.
Constructor Details
#initialize(name:, directives: [], response_fields: [], line: nil) ⇒ ScenarioNode
Create a new ScenarioNode
951 952 953 954 955 956 |
# File 'lib/synthra/parser/ast.rb', line 951 def initialize(name:, directives: [], response_fields: [], line: nil) super(line: line) @name = name @directives = directives @response_fields = response_fields end |
Instance Attribute Details
#directives ⇒ Object (readonly)
Returns the value of attribute directives.
935 936 937 |
# File 'lib/synthra/parser/ast.rb', line 935 def directives @directives end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
929 930 931 |
# File 'lib/synthra/parser/ast.rb', line 929 def name @name end |
#response_fields ⇒ Object (readonly)
Returns the value of attribute response_fields.
941 942 943 |
# File 'lib/synthra/parser/ast.rb', line 941 def response_fields @response_fields end |
Instance Method Details
#probability ⇒ Integer?
Get the probability from directives
973 974 975 976 |
# File 'lib/synthra/parser/ast.rb', line 973 def probability prob_directive = directives.find { |d| d.is_a?(ProbabilityDirective) } prob_directive&.percentage end |
#status_code ⇒ Integer?
Get the status code from directives
963 964 965 966 |
# File 'lib/synthra/parser/ast.rb', line 963 def status_code status_directive = directives.find { |d| d.is_a?(StatusDirective) } status_directive&.status_code end |