class ProcString

SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__

Attributes

file[RW]

Filename where the proc is defined

lines[RW]

Range of lines where the proc is defined

ex. (12..16)

Public Instance Methods

to_lambda() click to toggle source

Return a lambda

# File lib/proc_source.rb, line 36
def to_lambda
  to_proc "lambda"
end
to_proc(kind="proc") click to toggle source

Return a Proc object If lines and file is specified, these are tied to the proc.

# File lib/proc_source.rb, line 24
def to_proc(kind="proc")
  if @file && @lines
    raise "#lines must be a range" unless @lines.kind_of? Range
    result = eval("#{kind} #{self}", binding, @file, @lines.min)
  else
    result = eval("#{kind} #{self}")
  end
  result.source = self
  result
end