Sha256: ff3dd753f9fdb08b206fbe0878a16bbc210e3c90605c9de3ae7c1d49484abcaa

Contents?: true

Size: 553 Bytes

Versions: 4

Compression:

Stored size: 553 Bytes

Contents

require 'internal/node/as_code'
require 'internal/proc'
require 'internal/proc/signature'

class Proc
  # Return a string representation of a proc's definition/body,
  # similarly to +Method#as_code+.
  def as_code(indent=0)
    sig = self.signature
    body_expression = self.body ? self.body.as_code(indent+1) : nil
    s = "#{'  '*indent}proc do"
    if not sig.args.unspecified then
      s += " #{sig}"
    end
    s += "\n"
    if body_expression then
      s += "#{body_expression}\n"
    end
    s += "#{'  '*indent}end"
    return s
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ruby-decompiler-0.0.1 lib/decompiler/proc/as_code.rb
ruby-internal-0.8.2 lib/internal/proc/as_code.rb
ruby-internal-0.8.1 lib/internal/proc/as_code.rb
ruby-internal-0.8.0 lib/internal/proc/as_code.rb