class RedParse::ListInNode::BracketsGetNode

Attributes

lvalue[W]

Public Class Methods

new(receiver,lbrack,params,rbrack) click to toggle source
Calls superclass method RedParse::ListInNode::Node::new
# File lib/redparse/node.rb, line 5280
def initialize(receiver,lbrack,params,rbrack)
  case params
  when CommaOpNode
    h,arrowrange=params.extract_unbraced_hash
    params=Array.new params
    params[arrowrange]=[h] if arrowrange          
  when ArrowOpNode 
    h=HashLiteralNode.new(nil,params,nil)
    h.startline=params.startline
    h.endline=params.endline
    params=[h]
  when nil
    params=nil
  else 
    params=[params]
  end
  params.extend ListInNode if params
  @offset=receiver.offset
  super(receiver,params)
end

Public Instance Methods

image() click to toggle source
# File lib/redparse/node.rb, line 5303
def image; "(#{receiver.image}.[])" end
lvalue() click to toggle source
# File lib/redparse/node.rb, line 5344
def lvalue
  return @lvalue if defined? @lvalue
  @lvalue=true
end
lvalue_parsetree(o) click to toggle source
# File lib/redparse/node.rb, line 5337
def lvalue_parsetree(o)
  result=parsetree_no_fcall o
  result[0]=:attrasgn
  result[2]=:[]=
  result
end
name() click to toggle source
# File lib/redparse/node.rb, line 5301
def name; "[]" end
parsetree(o) click to toggle source
# File lib/redparse/node.rb, line 5313
def parsetree(o)
  result=parsetree_no_fcall o
  o[:quirks] and VarLikeNode===receiver and receiver.name=='self' and
    result[0..2]=[:fcall,:[]] 
  return result
end
parsetree_no_fcall(o) click to toggle source
# File lib/redparse/node.rb, line 5320
      def parsetree_no_fcall o
        params=params()
        output,star=param_list_parse(params,o)
#        receiver=receiver.parsetree(o)
        result=[:call, receiver.rescue_parsetree(o), :[], output]
        if params
          if star and params.size==1
            output.concat star
          else
            output.unshift :array 
            result[-1]=[:argscat, output, star.last] if star
          end
        else
          result.pop
        end
        return result
      end
unparse(o=default_unparse_options) click to toggle source
# File lib/redparse/node.rb, line 5305
def unparse o=default_unparse_options
  [ receiver.unparse(o).sub(/ \z/,''),
    '[',
    params&&params.map{|param| param.unparse o}.join(','),
    ']'
  ].join
end