Module: Adiwg_Citation

Defined in:
lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_citation.rb

Class Method Summary collapse

Class Method Details

.unpack(hCitation) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_citation.rb', line 17

def self.unpack(hCitation)

	# instance classes needed in script
	intMetadataClass = InternalMetadata.new
	intCitation = intMetadataClass.newCitation

	# citation - title
	if hCitation.has_key?('title')
		s = hCitation['title']
		if s != ''
			intCitation[:citTitle] = s
		end
	end

	# citation - date
	if hCitation.has_key?('date')
		aCitDates = hCitation['date']
		unless aCitDates.empty?
			aCitDates.each do |hCitDate|
				if hCitDate.has_key?('date')
					s = hCitDate['date']
					if s != ''
						intDateTime = Adiwg_DateTime.unpack(s)
						if hCitDate.has_key?('dateType')
							s = hCitDate['dateType']
							if s != ''
								intDateTime[:dateType] = s
							end
						end
						intCitation[:citDate] << intDateTime
					end
				end
			end
		end
	end

	# citation - edition
	if hCitation.has_key?('edition')
		s = hCitation['edition']
		if s != ''
			intCitation[:citEdition]  = s
		end
	end

	# citation - responsible party
	if hCitation.has_key?('responsibleParty')
		aRParty = hCitation['responsibleParty']
		unless aRParty.empty?
			aRParty.each do |hRParty|
				intCitation[:citResponsibleParty] << Adiwg_ResponsibleParty.unpack(hRParty)
			end
		end
	end

	# citation - presentation form
	if hCitation.has_key?('presentationForm')
		aPForms = hCitation['presentationForm']
		unless aPForms.empty?
			aPForms.each do |pForm|
				intCitation[:citResourceForms] << pForm
			end
		end
	end

	# citation - resource identifiers
	if hCitation.has_key?('identifier')
		aResIds = hCitation['identifier']
		aResIds.each do |hIdentifier|
			unless hIdentifier.empty?
				intCitation[:citResourceIDs] << Adiwg_ResourceIdentifier.unpack(hIdentifier)
			end
		end
	end

	# citation - online resources
	if hCitation.has_key?('onlineResource')
		aOlRes = hCitation['onlineResource']
		aOlRes.each do |hOlRes|
			unless hOlRes.empty?
				intCitation[:citOlResources] << Adiwg_OnlineResource.unpack(hOlRes)
			end
		end
	end

	return intCitation
end