Sha256: 3a051c20c3f9e8d5dfacf88cb68e1d1dccc008d64a59b0a79b655f35fd405a6c

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

class Proc

  # create a raw eval-able process source, so you can set
  # the right bindings using the .to_proc call from String methods
  def source

    # defaults
    begin
      return_string= ProcSource.new
      block= 0
    end

    unless inspect.nil?
      return ProcSource.source_cache[self.inspect]
    else

      File.open(File.expand_path(self.source_location[0])
      ).each_line_from self.source_location[1] do |line|
        block += line.source_formater_for_line_sub
        return_string.concat(line)
        break if block == 0
      end

      return_string.sub!(/^[\w\W]*Proc.new\s*{/,'Proc.new{')
      return_string.sub!(/}[^}]*$/,"}")

      if !return_string.include?('Proc.new')
        return_string.sub!(/^[^{]*(?!={)/,'Proc.new')
      end

      ProcSource.source_cache[self.inspect]= return_string

      return return_string
    end
  end
  alias :source_string :source

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
procemon-0.4.5 lib/procemon/function/proc_source/proc.rb