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.
948 949 950 951 952 953 954 955 956 957 958 959 960 |
# File 'lib/yadriggy/ast.rb', line 948 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.
940 941 942 |
# File 'lib/yadriggy/ast.rb', line 940 def array @array end |
#indexes ⇒ Array<ASTnode> (readonly)
Returns all the comma-separated indexes. It may be an empty array.
944 945 946 |
# File 'lib/yadriggy/ast.rb', line 944 def indexes @indexes end |
Class Method Details
.tag ⇒ Object
946 |
# File 'lib/yadriggy/ast.rb', line 946 def self.tag() :aref end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
965 966 967 |
# File 'lib/yadriggy/ast.rb', line 965 def accept(evaluator) evaluator.array_ref(self) end |