Sha256: 2d5cdd9dddfc639b4b82e568a03c6b7a78c7645b994c5d3b371c934cfff1f891

Contents?: true

Size: 851 Bytes

Versions: 26

Compression:

Stored size: 851 Bytes

Contents

module RelatonIsoBib
  # Iso ICS classificator.
  class Ics < Isoics::ICS
    # @param code [String, NilClass]
    # @param field [Integer, NilClass]
    # @param group [Integer, NilClass]
    # @param subgroup [Integer, NilClass]
    def initialize(code = nil, field: nil, group: nil, subgroup: nil)
      unless code || field
        raise ArgumentError, "wrong arguments (should be string or { fieldcode: [String] }"
      end

      field, group, subgroup = code.split "." if code
      super fieldcode: field, groupcode: group, subgroupcode: subgroup
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.ics do
        builder.code code
        builder.text_ description
      end
    end

    # @return [Hash]
    def to_hash
      hash = {}
      hash["code"] = code if code
      hash
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/relaton-iso-bib-1.2.0/lib/relaton_iso_bib/ics.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/relaton-iso-bib-1.2.0/lib/relaton_iso_bib/ics.rb
relaton-iso-bib-1.2.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-1.1.1 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-1.1.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-1.0.1 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-1.0.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.9.2 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.9.1 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.9.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.8.1 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.8.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.7.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.6.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.5.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.4.1 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.4.0 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.3.12 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.3.11 lib/relaton_iso_bib/ics.rb
relaton-iso-bib-0.3.10 lib/relaton_iso_bib/ics.rb