Class: RelatonOmg::OmgBibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_omg/omg_bibliographic_item.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ RelatonOmg::OmgBibliographicItem

Parameters:

  • hash (Hash)

Returns:



13
14
15
16
# File 'lib/relaton_omg/omg_bibliographic_item.rb', line 13

def from_hash(hash)
  bib_hash = RelatonOmg::HashConverter.hash_to_bib(hash)
  new(**bib_hash)
end

.from_xml(file) ⇒ RelatonOmg::OmgBibliographicItem

Parameters:

  • file (String)

    path to XML file

Returns:



20
21
22
# File 'lib/relaton_omg/omg_bibliographic_item.rb', line 20

def from_xml(file)
  XMLParser.from_xml File.read file, encoding: "UTF-8"
end

.from_yaml(file) ⇒ RelatonOmg::OmgBibliographicItem

Parameters:

  • file (String)

    path to YAML file

Returns:



7
8
9
# File 'lib/relaton_omg/omg_bibliographic_item.rb', line 7

def from_yaml(file)
  from_hash YAML.load_file(file)
end

Instance Method Details

#ext_schemaString

Fetches flavor shcema version from XML

Returns:

  • (String)

    flavor shcema version



30
31
32
# File 'lib/relaton_omg/omg_bibliographic_item.rb', line 30

def ext_schema
  @ext_schema ||= schema_versions["relaton-model-omg"]
end

#to_xml(**opts) ⇒ String

Returns XML.

Parameters:

  • opts (Hash)

Options Hash (**opts):

  • :builder (Nokogiri::XML::Builder)

    XML builder

  • :bibdata (Boolean)
  • :lang (String)

    language

Returns:

  • (String)

    XML



39
40
41
42
# File 'lib/relaton_omg/omg_bibliographic_item.rb', line 39

def to_xml(**opts)
  opts[:date_format] ||= :short
  super
end