0.0
No commit activity in last 3 years
No release in over 3 years
When a class is interpreted and does not have the required methods, it throws an error.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
>= 0
 Project Readme

RubyInterface Build Status

Allows you to create abstract classes and interfaces in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'ruby_interface'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby_interface

Usage

Named Classes

class SpaceShip
  include RubyInterface

  defines :engine, :computer
end

class Enterprise < SpaceShip
end
# => NotImplementedError, 'Expected Enterprise to define #engine, #computer'

Anonymous classes

class SpaceShip
  include RubyInterface

  defines :engine, :computer
end

# If the block is passed in to Class::new
space_ship = Class.new(SpaceShip) { }
# => NotImplementedError, 'Expected Enterprise to define #engine, #computer'

# If the block is not passed in to Class::new
space_ship = Class.new(SpaceShip)
space_ship.class_eval { }

# => NotImplementedError, 'Expected Enterprise to define #engine, #computer'
# NOTE: After the first `class_eval`, the rest of the calls to it will not check whether methods are defined.
# NOTE: `class_exec` may also be used instead of `class_eval`

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kklimuk/ruby_interface.

License

The gem is available as open source under the terms of the MIT License.