Sha256: 76098c1acfcad0ab080adc6b92b3e7e69f27114baa18718a763231f262d034a3

Contents?: true

Size: 994 Bytes

Versions: 6

Compression:

Stored size: 994 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.10.0 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.9.0 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.8.0 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.7.3 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.7.2 lib/relaton_omg/omg_bibliographic_item.rb
relaton-omg-1.7.1 lib/relaton_omg/omg_bibliographic_item.rb