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
1073 1074 1075 1076 1077 1078 1079 1080 |
# File 'lib/yarp/node.rb', line 1073 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
1067 1068 1069 |
# File 'lib/yarp/node.rb', line 1067 def case_keyword_loc @case_keyword_loc end |
#conditions ⇒ Object (readonly)
attr_reader conditions: Array
1061 1062 1063 |
# File 'lib/yarp/node.rb', line 1061 def conditions @conditions end |
#consequent ⇒ Object (readonly)
attr_reader consequent: Node?
1064 1065 1066 |
# File 'lib/yarp/node.rb', line 1064 def consequent @consequent end |
#end_keyword_loc ⇒ Object (readonly)
attr_reader end_keyword_loc: Location
1070 1071 1072 |
# File 'lib/yarp/node.rb', line 1070 def end_keyword_loc @end_keyword_loc end |
#predicate ⇒ Object (readonly)
attr_reader predicate: Node?
1058 1059 1060 |
# File 'lib/yarp/node.rb', line 1058 def predicate @predicate end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1083 1084 1085 |
# File 'lib/yarp/node.rb', line 1083 def accept(visitor) visitor.visit_case_node(self) end |
#case_keyword ⇒ Object
def case_keyword: () -> String
1102 1103 1104 |
# File 'lib/yarp/node.rb', line 1102 def case_keyword case_keyword_loc.slice end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1089 1090 1091 |
# File 'lib/yarp/node.rb', line 1089 def child_nodes [predicate, *conditions, consequent] end |
#deconstruct_keys(keys) ⇒ Object
1097 1098 1099 |
# File 'lib/yarp/node.rb', line 1097 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
1107 1108 1109 |
# File 'lib/yarp/node.rb', line 1107 def end_keyword end_keyword_loc.slice end |