README

Path: README
Last Update: Sun Jun 05 15:49:07 Mountain Daylight Time 2005

Description

   This module provides Java style interfaces for Ruby, including a fairly
   similar syntax.  I don't necessarily believe in interfaces, but I wanted to
   put it out there as proof that it could be done.  Frankly, Java needs mixins
   more than Ruby needs interfaces, but here you go.

Installation

Manual

   ruby test/ts_interface.rb
   ruby install.rb

Gem Install

   ruby interface.gemspec
   gem install interface-<version>.gem

Synopsis

   require "interface"

   MyInterface = interface{
      required_methods :foo, :bar, :baz
   }

   # Raises an error until 'baz' is defined
   class MyClass
      def foo
         puts "foo"
      end
      def bar
         puts "bar"
      end
      implements MyInterface
   end

General Notes

   Subinterfaces work as well.  See the test_sub.rb file under the 'test'
   directory for a sample.

Developer’s Notes

   A discussion on IRC with Mauricio Fernandez got us talking about traits.
   During that discussion I remembered a blog entry by David Naseby.  I
   revisited his blog entry (at http://homepages.ihug.com.au/~naseby/33.html)
   and took a closer look.

   Keep in mind that I also happened to be thinking about Java at the moment
   because of a recent job switch that involved coding in Java.  I was also
   trying to figure out what the purpose of interfaces were.

   As I read the first page of David Naseby's article I realized that,
   whether intended or not, he had implemented a rudimentary form of interfaces
   for Ruby.  When I discovered this, I talked about it some more with Mauricio
   and he and I (mostly him) fleshed out the rest of the module, including some
   syntax improvements.  The result is syntax and functionality that is nearly
   identical to Java.

   I should note that, although I am listed as the author, this was mostly the
   combined work of David Naseby and Mauricio Fernandez.  I just happened to be
   the guy that put it all together.

Acknowledgements

   This module was largely inspired and somewhat copied from a post by
   David Naseby at http://homepages.ihug.com.au/~naseby/33.html.  It was
   subsequently modified almost entirely by Mauricio Fernandez through a
   series of discussions on IRC.

Copyright

   (C) 2004 Daniel J. Berger
   All rights reserved.

Warranty

   This package is provided "as is" and without any express or
   implied warranties, including, without limitation, the implied
   warranties of merchantability and fitness for a particular purpose.

License

   Ruby's

Author

   Daniel J. Berger (who mostly stole it from David Naseby, which was then
   modified by Mauricio Fernandez)
   djberg96 at gmail dot com
   imperator on IRC (irc.freenode.net)

[Validate]