Class: RedParse::ArrayLiteralNode
- Defined in:
- lib/redparse/node.rb
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
- #image ⇒ Object
-
#initialize(lbrack, contents, rbrack) ⇒ ArrayLiteralNode
constructor
A new instance of ArrayLiteralNode.
- #parsetree(o) ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from ValueNode
Methods inherited from Node
#+, #+@, #==, [], #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvalue, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #to_parsetree, #to_parsetree_and_warnings, #unary, #walk, #xform_tree!
Methods included from Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(lbrack, contents, rbrack) ⇒ ArrayLiteralNode
Returns a new instance of ArrayLiteralNode.
3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 |
# File 'lib/redparse/node.rb', line 3969 def initialize(lbrack,contents,rbrack) @offset=lbrack.offset contents or return super() if CommaOpNode===contents h,arrowrange=contents.extract_unbraced_hash contents[arrowrange]=[h] if arrowrange super( *contents ) elsif ArrowOpNode===contents h=HashLiteralNode.new(nil,contents,nil) h.startline=contents.startline h.endline=contents.endline super HashLiteralNode.new(nil,contents,nil) else super contents end end |
Instance Method Details
#image ⇒ Object
3986 |
# File 'lib/redparse/node.rb', line 3986 def image; "([])" end |
#parsetree(o) ⇒ Object
3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 |
# File 'lib/redparse/node.rb', line 3992 def parsetree(o) size.zero? and return [:zarray] normals,star,amp=param_list_parse(self,o) result=normals.unshift :array if star if size==1 result=star else result=[:argscat, result, star.last] end end result end |
#unparse(o = default_unparse_options) ⇒ Object
3988 3989 3990 |
# File 'lib/redparse/node.rb', line 3988 def unparse o= "["+map{|item| unparse_nl(item,o,'')+item.unparse(o)}.join(', ')+"]" end |