Class: Obp::Access::Renderer::Elements::SectionType

Inherits:
Object
  • Object
show all
Defined in:
lib/obp/access/elements/section_type.rb

Constant Summary collapse

FIXED_TYPES =
{
  "1" => "scope",
  "2" => "norm-refs",
}.freeze

Class Method Summary collapse

Class Method Details

.for(id) ⇒ Object



13
14
15
# File 'lib/obp/access/elements/section_type.rb', line 13

def self.for(id)
  FIXED_TYPES[id] || infer_from_pattern(id)
end

.infer_from_pattern(id) ⇒ Object



17
18
19
20
21
22
# File 'lib/obp/access/elements/section_type.rb', line 17

def self.infer_from_pattern(id)
  return "terms" if id.match?(/\A\d+\.\d*\z/)
  return "terms" if id.match?(/\A\d+\z/) && id.to_i >= 3

  nil
end