Permalink
Browse files

Allow the type of the Eye to be specified in .new.

The type of the Eye can now be given in the constructor and accessed via the
.type instance method.
  • Loading branch information...
1 parent ccb8bda commit 15f6ec0d6eb426c47f779587239582fbedcde9f3 @runpaint committed Apr 26, 2009
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/eye.rb
View
@@ -1,10 +1,13 @@
class Eye
+ DEFAULT_TYPE = :hash
+ attr_reader :type
def initialize(args={})
unless args.empty?
raise ArgumentError unless Hash === args
raise ArgumentError if args.keys.size != 1 || args.keys.first != :type
raise ArgumentError unless Symbol === args.values.first
end
+ @type = args.key?(:type) ? args[:type] : DEFAULT_TYPE
@eye = Hash.new(0)
end

0 comments on commit 15f6ec0

Please sign in to comment.