Class: Shaf::RegistrableFactory::Entry
- Inherits:
-
Object
- Object
- Shaf::RegistrableFactory::Entry
- Defined in:
- lib/shaf/registrable_factory.rb
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
Instance Method Summary collapse
- #identifier_count ⇒ Object
-
#initialize(clazz) ⇒ Entry
constructor
A new instance of Entry.
- #match?(strings) ⇒ Boolean
- #usage ⇒ Object
Constructor Details
#initialize(clazz) ⇒ Entry
Returns a new instance of Entry.
17 18 19 |
# File 'lib/shaf/registrable_factory.rb', line 17 def initialize(clazz) @clazz = clazz end |
Instance Attribute Details
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
15 16 17 |
# File 'lib/shaf/registrable_factory.rb', line 15 def clazz @clazz end |
Instance Method Details
#identifier_count ⇒ Object
27 28 29 |
# File 'lib/shaf/registrable_factory.rb', line 27 def identifier_count identifiers&.size || 0 end |
#match?(strings) ⇒ Boolean
21 22 23 24 25 |
# File 'lib/shaf/registrable_factory.rb', line 21 def match?(strings) raise NoIdentifiersError, clazz unless identifiers return false if strings.size < identifiers.size identifiers.zip(strings).all? { |pattern, str| matching_identifier? str, pattern } end |
#usage ⇒ Object
31 32 33 |
# File 'lib/shaf/registrable_factory.rb', line 31 def usage clazz.instance_variable_get(:@usage) end |