Class: Cosing::Annex::Base
- Inherits:
-
Object
- Object
- Cosing::Annex::Base
- Defined in:
- lib/cosing/annex/base.rb
Instance Method Summary collapse
- #add_rule(params) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #keys ⇒ Object
- #lookup(reference_number) ⇒ Object
Constructor Details
#initialize ⇒ Base
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 |
#keys ⇒ Object
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 |