Sha256: b1bfca04350c3dbda6d3436319e91b62968a60661d5833a344c987a5bd558710
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module Isoics class Note # @return [String] attr_reader :text, :ics_code # @param note [Hash] def initialize(note) @text, @ics_code = note.values_at(:text, :"ics-code") end # Fetch referenced ICS. # @return [Isoics::ICS] def ics Isoics.fetch ics_code if ics_code end end class ICS # @return [String] attr_reader(:code, :fieldcode, :groupcode, :subgroupcode, :description, :description_full) # @return [Array<Isoics::Note>] attr_reader :notes # @param ics_data [Hash] def initialize(fieldcode:, groupcode: nil, subgroupcode: nil) file_name = "#{__dir__}/../../ics/#{fieldcode}" 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
isoics-0.1.11 | lib/isoics/ics.rb |
isoics-0.1.10 | lib/isoics/ics.rb |