Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Failed to load latest commit information.
demo :admin: Require AE for testing.
index :admin: Require AE for testing.
lib Bump to version 1.0.2. [admin]
test admin: typos and such
work :admin: Routine upkeep.
.gemspec :admin: Routine upkeep.
.gitignore :admin: Routine upkeep.
.index :admin: Update .index file.
.travis.yml :admin: Add Travis CI confg.
.yardopts Add .yardopts to project.
Assembly Use var over Profile and move spec to demo. [admin] :test: Convert QED demos to Markdown.
Gemfile :admin: Add Gemfile. :admin: Routine upkeep.
LICENSE.txt :admin: Routine upkeep.
MANIFEST :doc: Update notes. :admin: Require AE for testing.


Gem Version Build Status Fork Me Report Issue Gittip

Homepage · Development · Report Issue

Platypus provides a generalized type conversion system, method overloading and psuedo-classes for the Ruby programming language.


Type conversion work like a rational duck might expect.

  "1234".to(Float)    => 1234.0  (Float)

  Time.from("6:30")   => 1234.0  (Time)

You can of course define your own.

  class X
    typecast String do |x|

To overload a method, mixin the Overloadable module and use the #overload (or #sig) method to define new functionality based on a specified type interface.

  class X
    include Overloadable

    def f

    sig Integer
    def f(i)

    sig String, String
    def f(s1, s2)
      [s1, s2].join('+')

  x =

  x.f          #=> "f"
  x.f(1)       #=> "f1"
  x.f("A","B") #=> "A+B"

Finally, the Platypus gives you the Type superclass (aka pseudo-classes).

  class KiloType < Type
    x % 1000 == 0

  KiloType === 1000
  KiloType === 2000

To learn more about using Platypus see the Demonstrundum.


To install with RubyGems simply open a console and type:

$ gem install platypus

Or add it as a dependency to your Gemfile.

gem "platypus"

Old school site installation can be achieved with Setup.rb (gem install setup), then download the tarball package and type:

$ tar -xvzf platypus-1.0.0.tgz
$ cd platypus-1.0.0
$ setup.rb all

Windows users use 'ruby setup.rb all'.


  • Thomas Sawyer (trans)
  • Jonas Pfenniger


Copyright (c) 2010 Rubyworks

This program is ditributed unser the terms of the FreeBSD license.

See LICENSE.txt file for details.

 _   ___
/ \ /   \
\. |: cc|     .---------.
 (.|:,---,   <  Feel the \
 (.|: \ c|    \ POWER!!! /
 (.    y-'     '--------'
  \ _ /
   m m
Something went wrong with that request. Please try again.