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
Returns a new instance of ICS.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/isoics/ics.rb', line 27 def initialize(fieldcode:, groupcode: nil, subgroupcode: nil) file_name = "#{__dir__}/../../ics/#{fieldcode.to_s}" file_name << "_#{groupcode}" if groupcode file_name << "_#{subgroupcode}" if subgroupcode file_name << ".json" 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 = if ics_data[:notes] ics_data[:notes].map { |n| Note.new n } else [] 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 |