class DSL::Var

Constants

PRETTY_PRINT_INSTANCE_VARIABLES

Attributes

to_s[R]
value[R]
var[R]

Public Class Methods

new(table, arg) { |arg| ... } click to toggle source
# File ripper/tools/dsl.rb, line 85
def initialize(table, arg, &block)
  @var = table.new_var
  @value = yield arg
  @table = table
end

Public Instance Methods

[](idx) click to toggle source

Indexing.

$:1 -> v1=get_value($:1)
$:1[0] -> rb_ary_entry(v1, 0)
$:1[0..1] -> [rb_ary_entry(v1, 0), rb_ary_entry(v1, 1)]
*$:1[0..1] -> rb_ary_entry(v1, 0), rb_ary_entry(v1, 1)

Splat needs ‘[range]` because `Var` does not have the length info.

# File ripper/tools/dsl.rb, line 99
def [](idx)
  if ::Range === idx
    idx.map {|i| self[i]}
  else
    @table.fetch("#@var[#{idx}]") {"rb_ary_entry(#{@var}, #{idx})"}
  end
end
pretty_print_instance_variables() click to toggle source
# File ripper/tools/dsl.rb, line 79
def pretty_print_instance_variables
  PRETTY_PRINT_INSTANCE_VARIABLES
end