Class: OCR::Factory
- Inherits:
-
Object
- Object
- OCR::Factory
- Defined in:
- lib/ocr/factory.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Factory
constructor
A new instance of Factory.
Constructor Details
#initialize(*args) ⇒ Factory
Returns a new instance of Factory.
9 10 11 |
# File 'lib/ocr/factory.rb', line 9 def initialize(*args) self.init(*args) if self.respond_to?(:init) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/ocr/factory.rb', line 3 def args @args end |
Class Method Details
.create(type = self.class, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ocr/factory.rb', line 13 def self.create(type = self.class, *args) raise ArgumentError, "Cannot create instance of #{type} from #{self.name}" if type == self raise ArgumentError, "Type cannot be nil" if type.nil? if !type.ancestors.include?(self) raise ArgumentError, "#{type.name} is not a descendant of #{self.name}" end type.new(*args) end |