Sha256: 4289ba52149b9b0ad6b2c01b239e5f2c68424b855cf1db639d76d665b89a2cb2

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

NAME

  prototype.rb

URIS

  http://codeforpeople.com/lib/ruby/
  http://rubyforge.org/projects/codeforpeople/

SYNOPSIS

  prototype.rb implements the prototype design pattern

    http://en.wikipedia.org/wiki/Prototype-based_programming

  for ruby

WHY

  prototype based programming can look very nice ;-)

EXAMPLES

  ~ > cat samples/a.rb
  require 'prototype'

  singleton = Prototype.new{
    @a, @b = 40, 2

    def answer() @a + @b end
  }

  p singleton.answer


  ~ > ruby samples/a.rb
  42




  ~ > cat samples/b.rb
  require 'prototype'

  DB = Prototype.new{
    host 'localhost'
    port 4242

    def connect() p [host, port] end
  }

  p DB
  p DB.host
  p DB.port
  DB.connect


  ~ > ruby samples/b.rb
  "localhost"
  4242
  ["localhost", 4242]
  

DOCS

  see

    lib/*rb
    samples/*rb

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prototype-0.0.0 README