Module: RelatonBib
- Defined in:
- lib/relaton_bib/contribution_info.rb,
lib/relaton_bib.rb,
lib/relaton_bib/medium.rb,
lib/relaton_bib/person.rb,
lib/relaton_bib/series.rb,
lib/relaton_bib/version.rb,
lib/relaton_bib/validity.rb,
lib/relaton_bib/typed_uri.rb,
lib/relaton_bib/xml_parser.rb,
lib/relaton_bib/biblio_note.rb,
lib/relaton_bib/contributor.rb,
lib/relaton_bib/hash_to_bib.rb,
lib/relaton_bib/organization.rb,
lib/relaton_bib/workers_pool.rb,
lib/relaton_bib/formatted_ref.rb,
lib/relaton_bib/biblio_version.rb,
lib/relaton_bib/classification.rb,
lib/relaton_bib/hash_converter.rb,
lib/relaton_bib/document_status.rb,
lib/relaton_bib/formatted_string.rb,
lib/relaton_bib/localized_string.rb,
lib/relaton_bib/bib_item_locality.rb,
lib/relaton_bib/document_relation.rb,
lib/relaton_bib/bibliographic_date.rb,
lib/relaton_bib/bibliographic_item.rb,
lib/relaton_bib/typed_title_string.rb,
lib/relaton_bib/document_identifier.rb,
lib/relaton_bib/copyright_association.rb,
lib/relaton_bib/document_relation_collection.rb
Overview
Defined Under Namespace
Modules: PersonIdentifierType
Classes: Address, Affilation, BibItemLocality, BiblioNote, BibliographicDate, BibliographicItem, Classification, Contact, ContributionInfo, Contributor, ContributorRole, CopyrightAssociation, DocRelationCollection, DocumentIdentifier, DocumentRelation, DocumentStatus, Error, FormattedRef, FormattedString, FullName, HashConverter, LocalizedString, Medium, OrgIdentifier, Organization, Person, PersonIdentifier, RequestError, Series, TypedTitleString, TypedUri, Validity, WorkersPool, XMLParser
Constant Summary
collapse
- VERSION =
"0.3.3".freeze
Class Method Summary
collapse
Class Method Details
.array(a) ⇒ Object
42
43
44
45
46
|
# File 'lib/relaton_bib/hash_to_bib.rb', line 42
def array(a)
return [] unless a
return [].push(a) unless a.is_a?(Array)
a
end
|
.hash_to_bib(args, nested = false) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/relaton_bib/hash_to_bib.rb', line 3
def hash_to_bib(args, nested = false)
return nil unless args.is_a?(Hash)
ret = Marshal.load(Marshal.dump(symbolize(args))) timestamp_hash(ret) unless nested
title_hash_to_bib(ret)
link_hash_to_bib(ret)
language_hash_to_bib(ret)
script_hash_to_bib(ret)
dates_hash_to_bib(ret)
docid_hash_to_bib(ret)
version_hash_to_bib(ret)
biblionote_hash_to_bib(ret)
abstract_hash_to_bib(ret)
formattedref_hash_to_bib(ret)
docstatus_hash_to_bib(ret)
contributors_hash_to_bib(ret)
relations_hash_to_bib(ret)
series_hash_to_bib(ret)
medium_hash_to_bib(ret)
place_hash_to_bib(ret)
extent_hash_to_bib(ret)
accesslocation_hash_to_bib(ret)
classification_hash_to_bib(ret)
validity_hash_to_bib(ret)
ret
end
|
.localizedstring(f) ⇒ Object
.localname(f, c) ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/relaton_bib/hash_to_bib.rb', line 48
def localname(f, c)
return nil if f.nil?
f.is_a?(Hash) and lang = f[:language]
lang ||= c[:name][:language]
f.is_a?(Hash) and script = f[:script]
script ||= c[:name][:script]
f.is_a?(Hash) ?
RelatonBib::LocalizedString.new(f[:content], lang, script) :
RelatonBib::LocalizedString.new(f, lang, script)
end
|
.symbolize(obj) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/relaton_bib/hash_to_bib.rb', line 34
def symbolize(obj)
obj.is_a? Hash and
return obj.inject({}){|memo,(k,v)| memo[k.to_sym] = symbolize(v); memo}
obj.is_a? Array and
return obj.inject([]){|memo,v | memo << symbolize(v); memo}
return obj
end
|
.timestamp_hash(ret) ⇒ Object
30
31
32
|
# File 'lib/relaton_bib/hash_to_bib.rb', line 30
def timestamp_hash(ret)
ret[:fetched] ||= Date.today.to_s
end
|