Class: Cosing::Annex::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cosing/annex/base.rb

Direct Known Subclasses

II, III, IV, V, VI

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



6
7
8
# File 'lib/cosing/annex/base.rb', line 6

def initialize
  @rules = {}
end

Instance Method Details

#add_rule(params) ⇒ Object



14
15
16
17
18
19
# File 'lib/cosing/annex/base.rb', line 14

def add_rule(params)
  return unless reference = params[:reference_number]

  annex = self.class.name.gsub("::", " ")
  @rules[reference] = self.class::Rule.new(**params.merge(annex:))
end

#keysObject



10
11
12
# File 'lib/cosing/annex/base.rb', line 10

def keys
  @rules.keys
end

#lookup(reference_number) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/cosing/annex/base.rb', line 21

def lookup(reference_number)
  @rules.fetch(
    reference_number.to_s,
    fuzzy_find(reference_number.to_s)
  )
rescue KeyError
  nil
end