class ActionView::RenderParser::RipperASTParser::Node

:nodoc:
:nodoc:

def argument_nodes

def argument_nodes
  raise unless fcall?
  return [] if self[1].nil?
  if self[1].last == false || self[1].last.type == :vcall
    self[1][0...-1]
  else
    self[1][0..-1]
  end
end

def call?

def call?
  type == :call
end

def call_method_name

def call_method_name
  self.last.first
end

def children

def children
  to_a
end

def fcall?

def fcall?
  type == :command || type == :fcall
end

def fcall_named?(name)

def fcall_named?(name)
  fcall? &&
    self[0].type == :@ident &&
    self[0][0] == name
end

def hash?

def hash?
  type == :bare_assoc_hash || type == :hash
end

def hash_from_body(body)

def hash_from_body(body)
  body.map do |hash_node|
    return nil if hash_node.type != :assoc_new
    [hash_node[0], hash_node[1]]
  end.to_h
end

def initialize(type, arr, opts = {})

def initialize(type, arr, opts = {})
  @type = type
  super(arr)
end

def inspect

def inspect
  typeinfo = type && type != :list ? ":" + type.to_s + ", " : ""
  "s(" + typeinfo + map(&:inspect).join(", ") + ")"
end

def string?

def string?
  type == :string_literal
end

def symbol?

def symbol?
  type == :@label || type == :symbol_literal
end

def to_hash

def to_hash
  if type == :bare_assoc_hash
    hash_from_body(self[0])
  elsif type == :hash && self[0] == nil
    {}
  elsif type == :hash && self[0].type == :assoclist_from_args
    hash_from_body(self[0][0])
  end
end

def to_string

def to_string
  raise unless string?
  self[0][0][0]
end

def to_symbol

def to_symbol
  if type == :@label && self[0] =~ /\A(.+):\z/
    $1.to_sym
  elsif type == :symbol_literal && self[0].type == :symbol && self[0][0].type == :@ident
    self[0][0][0].to_sym
  else
    raise "not a symbol?: #{self.inspect}"
  end
end

def variable_name

def variable_name
  self[0][0]
end

def variable_reference?

def variable_reference?
  type == :var_ref
end

def vcall?

def vcall?
  type == :vcall
end