Sha256: b8cee97e1e76e41396a873be5b36a4ac3c31b56f62caf30325a9d4ccf42642dd

Contents?: true

Size: 961 Bytes

Versions: 88

Compression:

Stored size: 961 Bytes

Contents

module RelatonBib
  class Classification
    # @return [String, NilClass]
    attr_reader :type

    # @return [String]
    attr_reader :value

    # @param type [String, NilClass]
    # @param value [String]
    def initialize(type: nil, value:)
      @type  = type
      @value = value
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      xml = builder.classification value
      xml[:type] = type if type
    end

    # @return [Hash]
    def to_hash
      hash = { "value" => value }
      hash["type"] = type if type
      hash
    end

    # @param prefix [String]
    # @param count [Integer] number of classifications
    # @return [String]
    def to_asciibib(prefix = "", count = 1)
      pref = prefix.empty? ? "classification" : prefix + ".classification"
      out = count > 1 ? "#{pref}::\n" : ""
      out += "#{pref}.type:: #{type}\n" if type
      out += "#{pref}.value:: #{value}\n"
      out
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
relaton-bib-1.14.2 lib/relaton_bib/classification.rb
relaton-bib-1.14.1 lib/relaton_bib/classification.rb
relaton-bib-1.14.0 lib/relaton_bib/classification.rb
relaton-bib-1.13.15 lib/relaton_bib/classification.rb
relaton-bib-1.13.14 lib/relaton_bib/classification.rb
relaton-bib-1.13.13 lib/relaton_bib/classification.rb
relaton-bib-1.13.12 lib/relaton_bib/classification.rb
relaton-bib-1.13.11 lib/relaton_bib/classification.rb
relaton-bib-1.13.10 lib/relaton_bib/classification.rb
relaton-bib-1.13.9 lib/relaton_bib/classification.rb
relaton-bib-1.13.8 lib/relaton_bib/classification.rb
relaton-bib-1.13.7 lib/relaton_bib/classification.rb
relaton-bib-1.13.6 lib/relaton_bib/classification.rb
relaton-bib-1.13.5 lib/relaton_bib/classification.rb
relaton-bib-1.13.4 lib/relaton_bib/classification.rb
relaton-bib-1.13.3 lib/relaton_bib/classification.rb
relaton-bib-1.13.2 lib/relaton_bib/classification.rb
relaton-bib-1.13.1 lib/relaton_bib/classification.rb
relaton-bib-1.13.0 lib/relaton_bib/classification.rb
relaton-bib-1.12.7 lib/relaton_bib/classification.rb