Class: PseudoBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/parsely.rb

Defined Under Namespace

Classes: PerlVar

Constant Summary collapse

PerlNil =
PerlVar.new ''

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lineno, vals) ⇒ PseudoBinding

Returns a new instance of PseudoBinding.



57
58
59
# File 'lib/parsely.rb', line 57

def initialize lineno, vals
  @line, @vals = PerlVar.new(lineno.to_s), vals.map {|x| PerlVar.new(x)}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/parsely.rb', line 60

def method_missing name, *args
  if args.empty?
    if name =~ /_(\d+)/
      @vals[$1.to_i] || PerlNil
    else
      name.to_s
    end
  else
    super
  end
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



55
56
57
# File 'lib/parsely.rb', line 55

def line
  @line
end

#valsObject (readonly)

Returns the value of attribute vals.



56
57
58
# File 'lib/parsely.rb', line 56

def vals
  @vals
end