Sha256: 4b9e8872d48e5de1115469a625da2034bd03d7b20d7b5eba44c983c3c23edc3f

Contents?: true

Size: 937 Bytes

Versions: 11

Compression:

Stored size: 937 Bytes

Contents

class Pen
  attr_reader :written, :color

  def initialize(color = :black)
    @color = color
    @written = []
  end

  def write(string)
    @written << string
    string
  end

  def write_block(&block)
    string = yield
    @written << string
    string
  end

  def write_hello
    write("hello")
  end

  def write_array(*args)
    args.each do |arg|
      write(arg)
    end
  end

  def greet(hello = "hello", name)
    write("#{hello} #{name}")
  end

  def public_method
  end

  def another
    "another"
  end

  protected
  def protected_method
  end

  private
  def private_method
  end

  class << self
    def another
      "another"
    end

    def public_method
    end

    protected
    def protected_method
    end

    private
    def private_method
    end

  end
end

another = "meta_method"

Pen.define_singleton_method(:meta_method) do
  another
end

Pen.send(:define_method, :meta_method) do
  another
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spy-0.4.5 test/support/pen.rb
spy-0.4.3 test/support/pen.rb
spy-0.4.2 test/support/pen.rb
spy-0.4.1 test/support/pen.rb
spy-0.4.0 test/support/pen.rb
spy-0.3.1 test/support/pen.rb
spy-0.3.0 test/support/pen.rb
spy-0.2.5 test/support/pen.rb
spy-0.2.4 test/support/pen.rb
spy-0.2.3 test/support/pen.rb
spy-0.2.2 test/support/pen.rb