Class: Isoics::ICS
- Inherits:
-
Object
- Object
- Isoics::ICS
- Defined in:
- lib/isoics/ics.rb
Instance Attribute Summary collapse
- #code ⇒ String readonly
- #description ⇒ String readonly
- #description_full ⇒ String readonly
- #fieldcode ⇒ String readonly
- #groupcode ⇒ String readonly
- #notes ⇒ Array<Isoics::Note> readonly
- #subgroupcode ⇒ String readonly
Instance Method Summary collapse
-
#initialize(fieldcode:, groupcode: nil, subgroupcode: nil) ⇒ ICS
constructor
A new instance of ICS.
Constructor Details
#initialize(fieldcode:, groupcode: nil, subgroupcode: nil) ⇒ ICS
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/isoics/ics.rb', line 27 def initialize(fieldcode:, groupcode: nil, subgroupcode: nil) sbgcode = groupcode && subgroupcode code = [fieldcode.to_s, groupcode, sbgcode].compact.join "." file_name = "#{__dir__}/../../ics/#{code.gsub('.', '_')}.json" if File.exist? file_name ics_data = JSON.parse File.read(file_name), symbolize_names: true @code, @fieldcode, @groupcode, @subgroupcode, @description, @description_full = ics_data.values_at( :code, :fieldcode, :groupcode, :subgroupcode, :description, :descriptionFull ) @notes = ics_data[:notes]&.map { |n| Note.new n } @notes ||= [] else warn "[isoics] code #{code} not found in ICS list" @code = code @fieldcode = fieldcode @groupcode = groupcode @subgroupcode = sbgcode end end |
Instance Attribute Details
#code ⇒ String (readonly)
20 21 22 |
# File 'lib/isoics/ics.rb', line 20 def code @code end |
#description ⇒ String (readonly)
20 21 22 |
# File 'lib/isoics/ics.rb', line 20 def description @description end |
#description_full ⇒ String (readonly)
20 21 22 |
# File 'lib/isoics/ics.rb', line 20 def description_full @description_full end |
#fieldcode ⇒ String (readonly)
20 21 22 |
# File 'lib/isoics/ics.rb', line 20 def fieldcode @fieldcode end |
#groupcode ⇒ String (readonly)
20 21 22 |
# File 'lib/isoics/ics.rb', line 20 def groupcode @groupcode end |
#notes ⇒ Array<Isoics::Note> (readonly)
24 25 26 |
# File 'lib/isoics/ics.rb', line 24 def notes @notes end |
#subgroupcode ⇒ String (readonly)
20 21 22 |
# File 'lib/isoics/ics.rb', line 20 def subgroupcode @subgroupcode end |