Class: YARP::CaseNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::CaseNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of a case statement.
case true ^^^^^^^^^ when false end
Instance Attribute Summary collapse
-
#case_keyword_loc ⇒ Object
readonly
attr_reader case_keyword_loc: Location.
-
#conditions ⇒ Object
readonly
attr_reader conditions: Array.
-
#consequent ⇒ Object
readonly
attr_reader consequent: Node?.
-
#end_keyword_loc ⇒ Object
readonly
attr_reader end_keyword_loc: Location.
-
#predicate ⇒ Object
readonly
attr_reader predicate: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#case_keyword ⇒ Object
def case_keyword: () -> String.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
- #deconstruct_keys(keys) ⇒ Object
-
#end_keyword ⇒ Object
def end_keyword: () -> String.
-
#initialize(predicate, conditions, consequent, case_keyword_loc, end_keyword_loc, location) ⇒ CaseNode
constructor
def initialize: (predicate: Node?, conditions: Array, consequent: Node?, case_keyword_loc: Location, end_keyword_loc: Location, location: Location) -> void.
Constructor Details
#initialize(predicate, conditions, consequent, case_keyword_loc, end_keyword_loc, location) ⇒ CaseNode
def initialize: (predicate: Node?, conditions: Array, consequent: Node?, case_keyword_loc: Location, end_keyword_loc: Location, location: Location) -> void
1064 1065 1066 1067 1068 1069 1070 1071 |
# File 'lib/yarp/node.rb', line 1064 def initialize(predicate, conditions, consequent, case_keyword_loc, end_keyword_loc, location) @predicate = predicate @conditions = conditions @consequent = consequent @case_keyword_loc = case_keyword_loc @end_keyword_loc = end_keyword_loc @location = location end |
Instance Attribute Details
#case_keyword_loc ⇒ Object (readonly)
attr_reader case_keyword_loc: Location
1058 1059 1060 |
# File 'lib/yarp/node.rb', line 1058 def case_keyword_loc @case_keyword_loc end |
#conditions ⇒ Object (readonly)
attr_reader conditions: Array
1052 1053 1054 |
# File 'lib/yarp/node.rb', line 1052 def conditions @conditions end |
#consequent ⇒ Object (readonly)
attr_reader consequent: Node?
1055 1056 1057 |
# File 'lib/yarp/node.rb', line 1055 def consequent @consequent end |
#end_keyword_loc ⇒ Object (readonly)
attr_reader end_keyword_loc: Location
1061 1062 1063 |
# File 'lib/yarp/node.rb', line 1061 def end_keyword_loc @end_keyword_loc end |
#predicate ⇒ Object (readonly)
attr_reader predicate: Node?
1049 1050 1051 |
# File 'lib/yarp/node.rb', line 1049 def predicate @predicate end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1074 1075 1076 |
# File 'lib/yarp/node.rb', line 1074 def accept(visitor) visitor.visit_case_node(self) end |
#case_keyword ⇒ Object
def case_keyword: () -> String
1092 1093 1094 |
# File 'lib/yarp/node.rb', line 1092 def case_keyword case_keyword_loc.slice end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1079 1080 1081 |
# File 'lib/yarp/node.rb', line 1079 def child_nodes [predicate, *conditions, consequent] end |
#deconstruct_keys(keys) ⇒ Object
1087 1088 1089 |
# File 'lib/yarp/node.rb', line 1087 def deconstruct_keys(keys) { predicate: predicate, conditions: conditions, consequent: consequent, case_keyword_loc: case_keyword_loc, end_keyword_loc: end_keyword_loc, location: location } end |
#end_keyword ⇒ Object
def end_keyword: () -> String
1097 1098 1099 |
# File 'lib/yarp/node.rb', line 1097 def end_keyword end_keyword_loc.slice end |