Module: Relaton::Plateau::HashConverter

Extended by:
HashConverter
Includes:
RelatonBib::HashConverter
Included in:
HashConverter
Defined in:
lib/relaton/plateau/hash_converter.rb

Instance Method Summary collapse

Instance Method Details

#bib_item(item_hash) ⇒ RelatonCie::BibliographicItem

Parameters:

  • item_hash (Hash)

Returns:

  • (RelatonCie::BibliographicItem)


41
42
43
# File 'lib/relaton/plateau/hash_converter.rb', line 41

def bib_item(item_hash)
  BibItem.new(**item_hash)
end

#create_docid(**args) ⇒ Object



45
46
47
# File 'lib/relaton/plateau/hash_converter.rb', line 45

def create_docid(**args)
  Docidentifier.new(**args)
end

#create_doctype(**args) ⇒ Object



49
50
51
# File 'lib/relaton/plateau/hash_converter.rb', line 49

def create_doctype(**args)
  DocumentType.new(**args)
end

#hash_to_bib(args) ⇒ Hash

Parameters:

  • args (Hash)

Returns:

  • (Hash)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/relaton/plateau/hash_converter.rb', line 8

def hash_to_bib(args)
  ret = super
  return unless ret
  return ret unless ret[:ext]

  hash_to_bib_cover ret
  hash_to_bib_filesize ret
  hash_to_bib_stagename ret
  ret.delete :ext
  ret
end

#hash_to_bib_cover(ret) ⇒ Object



20
21
22
23
24
25
# File 'lib/relaton/plateau/hash_converter.rb', line 20

def hash_to_bib_cover(ret)
  return unless ret[:ext][:cover]

  image = ret[:ext][:cover][:image]
  ret[:cover] = Cover.new(RelatonBib::Image.new(**image))
end

#hash_to_bib_filesize(ret) ⇒ Object



27
28
29
30
31
# File 'lib/relaton/plateau/hash_converter.rb', line 27

def hash_to_bib_filesize(ret)
  return unless ret[:ext][:filesize]

  ret[:filesize] = ret[:ext][:filesize].to_i
end

#hash_to_bib_stagename(ret) ⇒ Object



33
34
35
36
37
# File 'lib/relaton/plateau/hash_converter.rb', line 33

def hash_to_bib_stagename(ret)
  return unless ret[:ext][:stagename]

  ret[:stagename] = Stagename.new(**ret[:ext][:stagename])
end