Class: Shaf::RegistrableFactory::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/registrable_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clazzObject (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_countObject



27
28
29
# File 'lib/shaf/registrable_factory.rb', line 27

def identifier_count
  identifiers&.size || 0
end

#match?(strings) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



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

#usageObject



31
32
33
# File 'lib/shaf/registrable_factory.rb', line 31

def usage
  clazz.instance_variable_get(:@usage)
end