Class: Yadriggy::ArrayRef
- Includes:
- AstHelper
- Defined in:
- lib/yadriggy/ast.rb
Overview
Array reference.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#array ⇒ ASTnode
readonly
The array object.
-
#indexes ⇒ Array<ASTnode>
readonly
All the comma-separated indexes.
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#initialize(sexp) ⇒ ArrayRef
constructor
A new instance of ArrayRef.
Methods included from AstHelper
#has_tag?, #to_node, #to_nodes
Methods inherited from ASTnode
#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class
Constructor Details
#initialize(sexp) ⇒ ArrayRef
Returns a new instance of ArrayRef.
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
# File 'lib/yadriggy/ast.rb', line 1018 def initialize(sexp) @array = to_node(sexp[1]) args_block = sexp[2] if args_block.nil? @indexes = [] else args = has_tag?(args_block, :args_add_block)[1] @indexes = to_nodes(args) end add_child(@array) add_children(@indexes) end |
Instance Attribute Details
#array ⇒ ASTnode (readonly)
Returns the array object.
1010 1011 1012 |
# File 'lib/yadriggy/ast.rb', line 1010 def array @array end |
#indexes ⇒ Array<ASTnode> (readonly)
Returns all the comma-separated indexes. It may be an empty array.
1014 1015 1016 |
# File 'lib/yadriggy/ast.rb', line 1014 def indexes @indexes end |
Class Method Details
.tag ⇒ Object
1016 |
# File 'lib/yadriggy/ast.rb', line 1016 def self.tag() :aref end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
1035 1036 1037 |
# File 'lib/yadriggy/ast.rb', line 1035 def accept(evaluator) evaluator.array_ref(self) end |