{"id":22981018,"url":"https://github.com/rubyworks/platypus","last_synced_at":"2025-06-27T10:07:26.249Z","repository":{"id":923742,"uuid":"689489","full_name":"rubyworks/platypus","owner":"rubyworks","description":"Ruby Knows Types","archived":false,"fork":false,"pushed_at":"2014-07-22T20:12:33.000Z","size":632,"stargazers_count":9,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T08:04:20.653Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubyworks.github.com/platypus","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-05-27T16:08:57.000Z","updated_at":"2015-02-28T16:42:29.000Z","dependencies_parsed_at":"2022-07-15T05:30:32.859Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/platypus","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rubyworks/platypus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fplatypus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fplatypus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fplatypus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fplatypus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/platypus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fplatypus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261186803,"owners_count":23121951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T01:46:44.935Z","updated_at":"2025-06-27T10:07:26.226Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Platypus\n\n[![Gem Version](http://img.shields.io/gem/v/platypus.svg?style=flat)](http://rubygems.org/gem/platypus)\n[![Build Status](http://img.shields.io/travis/rubyworks/platypus.svg?style=flat)](http://travis-ci.org/rubyworks/platypus)\n[![Fork Me](http://img.shields.io/badge/scm-github-blue.svg?style=flat)](http://github.com/rubyworks/platypus)\n[![Report Issue](http://img.shields.io/github/issues/rubyworks/platypus.svg?style=flat)](http://github.com/rubyworks/platypus/issues)\n[![Gittip](http://img.shields.io/badge/gittip-$1-green.svg?style=flat)](https://www.gittip.com/on/github/rubyworks/)\n\n[Homepage](http://rubyworks.github.com/platypus) \u0026middot;\n[Development](http://github.com/rubyworks/platypus) \u0026middot;\n[Report Issue](http://github.com/rubyworks/platypus/issues)\n\n\u003cb\u003ePlatypus provides a generalized type conversion system,\nmethod overloading and psuedo-classes for the Ruby programming\nlanguage.\u003c/b\u003e\n\n\n## Overview\n\nType conversion work like a rational duck might expect.\n\n```ruby\n  \"1234\".to(Float)    =\u003e 1234.0  (Float)\n\n  Time.from(\"6:30\")   =\u003e 1234.0  (Time)\n```\n\nYou can of course define your own.\n\n```ruby\n  class X\n    typecast String do |x|\n      \"#{x}\"\n    end\n  end\n```\n\nTo overload a method, mixin the Overloadable module and use the #overload (or #sig)\nmethod to define new functionality based on a specified type interface.\n\n```ruby\n  class X\n    include Overloadable\n\n    def f\n      \"f\"\n    end\n\n    sig Integer\n    def f(i)\n      \"f#{i}\"\n    end\n\n    sig String, String\n    def f(s1, s2)\n      [s1, s2].join('+')\n    end\n  end\n\n  x = X.new\n\n  x.f          #=\u003e \"f\"\n  x.f(1)       #=\u003e \"f1\"\n  x.f(\"A\",\"B\") #=\u003e \"A+B\"\n```\n\nFinally, the Platypus gives you the Type superclass (aka pseudo-classes).\n\n```ruby\n  class KiloType \u003c Type\n    x % 1000 == 0\n  end\n\n  KiloType === 1000\n  KiloType === 2000\n```\n\nTo learn more about using Platypus see the [Demonstrundum](http://rubyworks.github.com/platypus/docs/demo).\n\n\n## Installation\n\nTo install with RubyGems simply open a console and type:\n\n    $ gem install platypus\n\nOr add it as a dependency to your Gemfile.\n\n    gem \"platypus\"\n\nOld school site installation can be achieved with Setup.rb (gem install setup),\nthen download the tarball package and type:\n\n    $ tar -xvzf platypus-1.0.0.tgz\n    $ cd platypus-1.0.0\n    $ setup.rb all\n\nWindows users use 'ruby setup.rb all'.\n\n\n## Authors\n\n* Thomas Sawyer (trans)\n* Jonas Pfenniger\n\n\n## Copying\n\nCopyright (c) 2010 Rubyworks\n\nThis program is ditributed unser the terms of the *FreeBSD* license.\n\nSee LICENSE.txt file for details.\n\n\n\u003cbr/\u003e\u003cbr/\u003e\n\n     _   ___\n    / \\ /   \\\n    \\. |: cc|     .---------.\n     (.|:,---,   \u003c  Feel the \\\n     (.|: \\ c|    \\ POWER!!! /\n     (.    y-'     '--------'\n      \\ _ /\n       m m\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fplatypus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Fplatypus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fplatypus/lists"}