Class: Pubid::Iec::Renderer::Pubid
- Inherits:
-
Core::Renderer::Base
- Object
- Core::Renderer::Base
- Pubid::Iec::Renderer::Pubid
show all
- Defined in:
- lib/pubid/iec/renderer/pubid.rb
Instance Method Summary
collapse
-
#render_amendments(amendments, _opts, params) ⇒ Object
-
#render_conjuction_part(conjuction_parts, _opts, params) ⇒ Object
-
#render_copublisher(copublisher, _opts, _params) ⇒ Object
-
#render_corrigendums(corrigendums, _opts, _params) ⇒ Object
-
#render_database(database, _opts, _params) ⇒ Object
-
#render_day(day, opts, _params) ⇒ Object
-
#render_edition(edition, _opts, params) ⇒ Object
-
#render_fragment(fragment, _opts, _params) ⇒ Object
-
#render_identifier(params) ⇒ Object
-
#render_language(language, opts, _params) ⇒ Object
-
#render_month(month, opts, _params) ⇒ Object
-
#render_publisher(publisher, _opts, _params) ⇒ Object
-
#render_sheet(sheet, _opts, params) ⇒ Object
-
#render_stage(stage, _opts, params) ⇒ Object
-
#render_type(type, _opts, params) ⇒ Object
-
#render_typed_stage(typed_stage, _opts, _params) ⇒ Object
-
#render_vap(vap, _opts, _params) ⇒ Object
-
#render_version(version, _opts, params) ⇒ Object
-
#supplement_prefix(params) ⇒ Object
Instance Method Details
#render_amendments(amendments, _opts, params) ⇒ Object
57
58
59
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 57
def render_amendments(amendments, _opts, params)
supplement_prefix(params) + amendments.sort.map(&:to_s).join("+")
end
|
#render_conjuction_part(conjuction_parts, _opts, params) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 73
def render_conjuction_part(conjuction_parts, _opts, params)
conjunction_symbol = case params[:publisher]
when "IECEE"
"&"
else
","
end
if conjuction_parts.is_a?(Array)
conjuction_parts.map(&:to_i).sort.map { |conjuction_part| "#{conjunction_symbol}#{conjuction_part}" }.join
else
"#{conjunction_symbol}#{conjuction_parts}"
end
end
|
#render_copublisher(copublisher, _opts, _params) ⇒ Object
20
21
22
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 20
def render_copublisher(copublisher, _opts, _params)
"/" + Array(copublisher).join("/")
end
|
#render_corrigendums(corrigendums, _opts, _params) ⇒ Object
61
62
63
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 61
def render_corrigendums(corrigendums, _opts, _params)
"/" + corrigendums.sort.map(&:to_s).join("+")
end
|
#render_database(database, _opts, _params) ⇒ Object
49
50
51
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 49
def render_database(database, _opts, _params)
" DB" if database
end
|
#render_day(day, opts, _params) ⇒ Object
95
96
97
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 95
def render_day(day, opts, _params)
"-#{day}" if opts[:with_edition_month_date]
end
|
#render_edition(edition, _opts, params) ⇒ Object
69
70
71
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 69
def render_edition(edition, _opts, params)
" ED#{edition}" unless params[:version]
end
|
#render_fragment(fragment, _opts, _params) ⇒ Object
40
41
42
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 40
def render_fragment(fragment, _opts, _params)
"/FRAG#{fragment}"
end
|
#render_identifier(params) ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 3
def render_identifier(params)
format_string = "%{publisher}%{copublisher}%{type}%{typed_stage}%{stage} %{number}%{part}%{conjuction_part}"\
"%{part_version}%{version}%{iteration}"\
"%{year}%{month}%{day}%{sheet}%{amendments}%{vap}%{corrigendums}"\
"%{fragment}%{edition}%{database}"
format_string % params
end
|
#render_language(language, opts, _params) ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 99
def render_language(language, opts, _params)
if language.is_a?(Array)
"(#{language.map(&:to_s).sort.join('-')})"
else
"(#{language})"
end
end
|
#render_month(month, opts, _params) ⇒ Object
91
92
93
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 91
def render_month(month, opts, _params)
"-#{month}" if opts[:with_edition_month_date]
end
|
#render_publisher(publisher, _opts, _params) ⇒ Object
16
17
18
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 16
def render_publisher(publisher, _opts, _params)
publisher
end
|
#render_sheet(sheet, _opts, params) ⇒ Object
44
45
46
47
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 44
def render_sheet(sheet, _opts, params)
prefix = params[:part] ? "" : "-"
"#{prefix}/#{sheet[:number]}" + (sheet[:year] ? ":#{sheet[:year]}" : "")
end
|
#render_stage(stage, _opts, params) ⇒ Object
34
35
36
37
38
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 34
def render_stage(stage, _opts, params)
return if params[:typed_stage] || stage.abbr.nil?
" #{stage}"
end
|
#render_type(type, _opts, params) ⇒ Object
24
25
26
27
28
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 24
def render_type(type, _opts, params)
return if params[:stage].is_a?(::Pubid::Core::TypedStage)
" #{type}"
end
|
#render_typed_stage(typed_stage, _opts, _params) ⇒ Object
12
13
14
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 12
def render_typed_stage(typed_stage, _opts, _params)
" #{typed_stage}"
end
|
#render_vap(vap, _opts, _params) ⇒ Object
30
31
32
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 30
def render_vap(vap, _opts, _params)
" #{vap.join('-')}"
end
|
#render_version(version, _opts, params) ⇒ Object
65
66
67
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 65
def render_version(version, _opts, params)
"v#{params[:edition]}#{version}"
end
|
#supplement_prefix(params) ⇒ Object
53
54
55
|
# File 'lib/pubid/iec/renderer/pubid.rb', line 53
def supplement_prefix(params)
params[:vap]&.include?("CSV") ? "+" : "/"
end
|