Sha256: 2cd49fe316e4c3581bf07b3d76424e386bb5cf742e4e17b9627a6c15585a6438

Contents?: true

Size: 995 Bytes

Versions: 6

Compression:

Stored size: 995 Bytes

Contents

module RelatonOmg
  class OmgBibliographicItem < RelatonBib::BibliographicItem
    # @return [String, NilClass]
    class << self
      # @param file [String] path to YAML file
      # @return [RelatonOmg::OmgBibliographicItem]
      def from_yaml(file)
        from_hash YAML.load_file(file)
      end

      # @param hash [Hash]
      # @return [RelatonOmg::OmgBibliographicItem]
      def from_hash(hash)
        bib_hash = RelatonOmg::HashConverter.hash_to_bib(hash)
        new(**bib_hash)
      end

      # @param file [String] path to XML file
      # @return [RelatonOmg::OmgBibliographicItem]
      def from_xml(file)
        XMLParser.from_xml File.read file, encoding: "UTF-8"
      end
    end

    # @param opts [Hash]
    # @option opts [Nokogiri::XML::Builder] :builder XML builder
    # @option opts [Boolean] :bibdata
    # @option opts [String] :lang language
    # @return [String] XML
    def to_xml(**opts)
      opts[:date_format] ||= :short
      super
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
relaton-omg-1.13.0 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.12.0 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.11.2 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.11.1 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.11.0 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.10.1 lib/relaton_omg/omg_bibliographic_item.rb