relaton-bib 1.11.7 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/isodoc.rng CHANGED
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="admonition">
36
+ <element name="admonition">
37
+ <attribute name="type">
38
+ <ref name="AdmonitionType"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="class"/>
42
+ </optional>
43
+ <attribute name="id">
44
+ <data type="ID"/>
45
+ </attribute>
46
+ <optional>
47
+ <attribute name="uri">
48
+ <data type="anyURI"/>
49
+ </attribute>
50
+ </optional>
51
+ <optional>
52
+ <attribute name="coverpage">
53
+ <data type="boolean"/>
54
+ </attribute>
55
+ </optional>
56
+ <optional>
57
+ <attribute name="notag">
58
+ <data type="boolean"/>
59
+ </attribute>
60
+ </optional>
61
+ <optional>
62
+ <ref name="tname"/>
63
+ </optional>
64
+ <zeroOrMore>
65
+ <ref name="paragraph-with-footnote"/>
66
+ </zeroOrMore>
67
+ <zeroOrMore>
68
+ <ref name="note"/>
69
+ </zeroOrMore>
70
+ </element>
71
+ </define>
35
72
  <define name="index">
36
73
  <element name="index">
37
74
  <optional>
@@ -79,6 +116,11 @@
79
116
  <data type="boolean"/>
80
117
  </attribute>
81
118
  </optional>
119
+ <optional>
120
+ <attribute name="suppress_identifier">
121
+ <data type="boolean"/>
122
+ </attribute>
123
+ </optional>
82
124
  <ref name="BibliographicItem"/>
83
125
  </element>
84
126
  </define>
@@ -245,6 +287,9 @@
245
287
  <ref name="MultilingualRenderingType"/>
246
288
  </attribute>
247
289
  </optional>
290
+ <optional>
291
+ <ref name="tname"/>
292
+ </optional>
248
293
  <oneOrMore>
249
294
  <ref name="ul_li"/>
250
295
  </oneOrMore>
@@ -287,6 +332,9 @@
287
332
  </choice>
288
333
  </attribute>
289
334
  </optional>
335
+ <optional>
336
+ <ref name="tname"/>
337
+ </optional>
290
338
  <oneOrMore>
291
339
  <ref name="li"/>
292
340
  </oneOrMore>
@@ -323,6 +371,9 @@
323
371
  <ref name="MultilingualRenderingType"/>
324
372
  </attribute>
325
373
  </optional>
374
+ <optional>
375
+ <ref name="tname"/>
376
+ </optional>
326
377
  <oneOrMore>
327
378
  <ref name="dt"/>
328
379
  <ref name="dd"/>
@@ -657,6 +708,9 @@
657
708
  <optional>
658
709
  <attribute name="tag"/>
659
710
  </optional>
711
+ <optional>
712
+ <attribute name="type"/>
713
+ </optional>
660
714
  <optional>
661
715
  <attribute name="multilingual-rendering">
662
716
  <ref name="MultilingualRenderingType"/>
@@ -692,6 +746,9 @@
692
746
  <optional>
693
747
  <attribute name="tag"/>
694
748
  </optional>
749
+ <optional>
750
+ <attribute name="type"/>
751
+ </optional>
695
752
  <optional>
696
753
  <attribute name="multilingual-rendering">
697
754
  <ref name="MultilingualRenderingType"/>
@@ -851,6 +908,16 @@
851
908
  <ref name="MultilingualRenderingType"/>
852
909
  </attribute>
853
910
  </optional>
911
+ <optional>
912
+ <attribute name="coverpage">
913
+ <data type="boolean"/>
914
+ </attribute>
915
+ </optional>
916
+ <optional>
917
+ <attribute name="notag">
918
+ <data type="boolean"/>
919
+ </attribute>
920
+ </optional>
854
921
  <oneOrMore>
855
922
  <choice>
856
923
  <ref name="paragraph"/>
@@ -1178,6 +1245,7 @@
1178
1245
  <ref name="concept"/>
1179
1246
  <ref name="add"/>
1180
1247
  <ref name="del"/>
1248
+ <ref name="span"/>
1181
1249
  </choice>
1182
1250
  </define>
1183
1251
  <define name="add">
@@ -1204,6 +1272,14 @@
1204
1272
  </choice>
1205
1273
  </element>
1206
1274
  </define>
1275
+ <define name="span">
1276
+ <element name="span">
1277
+ <attribute name="class"/>
1278
+ <oneOrMore>
1279
+ <ref name="TextElement"/>
1280
+ </oneOrMore>
1281
+ </element>
1282
+ </define>
1207
1283
  <define name="concept">
1208
1284
  <element name="concept">
1209
1285
  <optional>
@@ -1994,6 +2070,7 @@
1994
2070
  <value>compare</value>
1995
2071
  <value>contrast</value>
1996
2072
  <value>see</value>
2073
+ <value>seealso</value>
1997
2074
  </choice>
1998
2075
  </define>
1999
2076
  <define name="deprecates">
@@ -17,7 +17,7 @@ module RelatonBib
17
17
  type_ptrn = %r{section|clause|part|paragraph|chapter|page|whole|table|
18
18
  annex|figure|note|list|example|volume|issue|time|
19
19
  locality:[a-zA-Z0-9_]+}x
20
- unless type.match? type_ptrn
20
+ unless type&.match? type_ptrn
21
21
  warn "[relaton-bib] WARNING: invalid locality type: #{type}"
22
22
  end
23
23
 
@@ -4,15 +4,12 @@ module RelatonBib
4
4
  class Version
5
5
  include RelatonBib
6
6
 
7
- # @return [String, NilClass]
8
- attr_reader :revision_date
7
+ # @return [String, nil]
8
+ attr_reader :revision_date, :draft
9
9
 
10
- # @return [Array<String>]
11
- attr_reader :draft
12
-
13
- # @param revision_date [String, NilClass]
14
- # @param draft [Array<String>]
15
- def initialize(revision_date = nil, draft = [])
10
+ # @param revision_date [String, nil]
11
+ # @param draft [String, nil]
12
+ def initialize(revision_date = nil, draft = nil)
16
13
  @revision_date = revision_date
17
14
  @draft = draft
18
15
  end
@@ -20,8 +17,8 @@ module RelatonBib
20
17
  # @param builder [Nokogiri::XML::Builder]
21
18
  def to_xml(builder)
22
19
  builder.version do
23
- builder.send("revision-date", revision_date) if revision_date
24
- draft.each { |d| builder.draft d }
20
+ builder.send(:"revision-date", revision_date) if revision_date
21
+ builder.draft draft if draft
25
22
  end
26
23
  end
27
24
 
@@ -29,19 +26,19 @@ module RelatonBib
29
26
  def to_hash
30
27
  hash = {}
31
28
  hash["revision_date"] = revision_date if revision_date
32
- hash["draft"] = single_element_array(draft) if draft&.any?
29
+ hash["draft"] = draft if draft
33
30
  hash
34
31
  end
35
32
 
36
33
  # @param prefix [String]
37
34
  # @return [String]
38
- def to_asciibib(prefix = "")
39
- pref = prefix.empty? ? prefix : prefix + "."
40
- out = ""
35
+ def to_asciibib(prefix = "", count = 1)
36
+ pref = prefix.empty? ? prefix : "#{prefix}."
37
+ out = count > 1 ? "#{prefix}version::\n" : ""
41
38
  if revision_date
42
39
  out += "#{pref}version.revision_date:: #{revision_date}\n"
43
40
  end
44
- draft&.each { |d| out += "#{pref}version.draft:: #{d}\n" }
41
+ out += "#{pref}version.draft:: #{draft}\n" if draft
45
42
  out
46
43
  end
47
44
  end
@@ -41,7 +41,8 @@ module RelatonBib
41
41
  when :year then parts[0]&.to_i
42
42
  when :month then parts[1]&.to_i
43
43
  when :day then parts[2]&.to_i
44
- else parse_date(d)
44
+ when :date then parse_date(d)
45
+ else d
45
46
  end
46
47
 
47
48
  # date.is_a?(Date) ? date.send(part) : date
@@ -28,6 +28,7 @@ require "relaton_bib/structured_identifier"
28
28
  require "relaton_bib/editorial_group"
29
29
  require "relaton_bib/ics"
30
30
  require "relaton_bib/bibliographic_size"
31
+ require "relaton_bib/edition"
31
32
 
32
33
  module RelatonBib
33
34
  # Bibliographic item
@@ -41,11 +42,14 @@ module RelatonBib
41
42
  webresource dataset archival social_media alert message
42
43
  conversation misc].freeze
43
44
 
44
- # @return [TrueClass, FalseClass, NilClass]
45
+ # @return [Boolean, nil]
45
46
  attr_accessor :all_parts
46
47
 
47
- # @return [String, NilClass]
48
- attr_reader :id, :type, :docnumber, :edition, :doctype, :subdoctype
48
+ # @return [String, nil]
49
+ attr_reader :id, :type, :docnumber, :doctype, :subdoctype
50
+
51
+ # @return [RelatonBib::Edition, nil] <description>
52
+ attr_reader :edition
49
53
 
50
54
  # @!attribute [r] title
51
55
  # @return [RelatonBib::TypedTitleStringCollection]
@@ -62,7 +66,7 @@ module RelatonBib
62
66
  # @return [Array<RelatonBib::ContributionInfo>]
63
67
  attr_reader :contributor
64
68
 
65
- # @return [RelatonBib::BibliographicItem::Version, NilClass]
69
+ # @return [Array<RelatonBib::BibliographicItem::Version>]
66
70
  attr_reader :version
67
71
 
68
72
  # @return [RelatonBib::BiblioNoteCollection]
@@ -74,13 +78,13 @@ module RelatonBib
74
78
  # @return [Array<String>] script Iso15924 code
75
79
  attr_reader :script
76
80
 
77
- # @return [RelatonBib::FormattedRef, NilClass]
81
+ # @return [RelatonBib::FormattedRef, nil]
78
82
  attr_reader :formattedref
79
83
 
80
84
  # @!attribute [r] abstract
81
85
  # @return [Array<RelatonBib::FormattedString>]
82
86
 
83
- # @return [RelatonBib::DocumentStatus, NilClass]
87
+ # @return [RelatonBib::DocumentStatus, nil]
84
88
  attr_reader :status
85
89
 
86
90
  # @return [Array<RelatonBib::CopyrightAssociation>]
@@ -92,7 +96,7 @@ module RelatonBib
92
96
  # @return [Array<RelatonBib::Series>]
93
97
  attr_reader :series
94
98
 
95
- # @return [RelatonBib::Medium, NilClass]
99
+ # @return [RelatonBib::Medium, nil]
96
100
  attr_reader :medium
97
101
 
98
102
  # @return [Array<RelatonBib::Place>]
@@ -107,7 +111,7 @@ module RelatonBib
107
111
  # @return [Array<Relaton::Classification>]
108
112
  attr_reader :classification
109
113
 
110
- # @return [RelatonBib:Validity, NilClass]
114
+ # @return [RelatonBib:Validity, nil]
111
115
  attr_reader :validity
112
116
 
113
117
  # @return [Date]
@@ -131,18 +135,18 @@ module RelatonBib
131
135
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
132
136
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
133
137
 
134
- # @param id [String, NilClass]
138
+ # @param id [String, nil]
135
139
  # @param title [RelatonBib::TypedTitleStringCollection,
136
140
  # Array<Hash, RelatonBib::TypedTitleString>]
137
- # @param formattedref [RelatonBib::FormattedRef, NilClass]
138
- # @param type [String, NilClass]
141
+ # @param formattedref [RelatonBib::FormattedRef, nil]
142
+ # @param type [String, nil]
139
143
  # @param docid [Array<RelatonBib::DocumentIdentifier>]
140
- # @param docnumber [String, NilClass]
144
+ # @param docnumber [String, nil]
141
145
  # @param language [Arra<String>]
142
146
  # @param script [Array<String>]
143
- # @param docstatus [RelatonBib::DocumentStatus, NilClass]
144
- # @param edition [String, NilClass]
145
- # @param version [RelatonBib::BibliographicItem::Version, NilClass]
147
+ # @param docstatus [RelatonBib::DocumentStatus, nil]
148
+ # @param edition [RelatonBib::Edition, nil]
149
+ # @param version [Array<RelatonBib::BibliographicItem::Version>]
146
150
  # @param biblionote [RelatonBib::BiblioNoteCollection]
147
151
  # @param series [Array<RelatonBib::Series>]
148
152
  # @param medium [RelatonBib::Medium, NilClas]
@@ -150,8 +154,8 @@ module RelatonBib
150
154
  # @param extent [Array<Relaton::Locality, RelatonBib::LocalityStack>]
151
155
  # @param accesslocation [Array<String>]
152
156
  # @param classification [Array<RelatonBib::Classification>]
153
- # @param validity [RelatonBib:Validity, NilClass]
154
- # @param fetched [Date, NilClass] default nil
157
+ # @param validity [RelatonBib:Validity, nil]
158
+ # @param fetched [Date, nil] default nil
155
159
  # @param keyword [Array<String>]
156
160
  # @param doctype [String]
157
161
  # @param subdoctype [String]
@@ -163,8 +167,8 @@ module RelatonBib
163
167
  # @param copyright [Array<Hash, RelatonBib::CopyrightAssociation>]
164
168
  # @option copyright [Array<Hash, RelatonBib::ContributionInfo>] :owner
165
169
  # @option copyright [String] :from
166
- # @option copyright [String, NilClass] :to
167
- # @option copyright [String, NilClass] :scope
170
+ # @option copyright [String, nil] :to
171
+ # @option copyright [String, nil] :scope
168
172
  #
169
173
  # @param date [Array<Hash, RelatonBib::BibliographicDate>]
170
174
  # @option date [String] :type
@@ -230,8 +234,12 @@ module RelatonBib
230
234
  @id = args[:id] || makeid(nil, false)
231
235
  @type = args[:type]
232
236
  @docnumber = args[:docnumber]
233
- @edition = args[:edition]
234
- @version = args[:version]
237
+ @edition = case args[:edition]
238
+ when Hash then Edition.new(**args[:edition])
239
+ when String then Edition.new(content: args[:edition])
240
+ else args[:edition]
241
+ end
242
+ @version = args.fetch :version, []
235
243
  @biblionote = args.fetch :biblionote, BiblioNoteCollection.new([])
236
244
  @language = args.fetch :language, []
237
245
  @script = args.fetch :script, []
@@ -321,7 +329,7 @@ module RelatonBib
321
329
  # @param opts [Hash]
322
330
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
323
331
  # @option opts [Boolean] :bibdata
324
- # @option opts [Symbol, NilClass] :date_format (:short), :full
332
+ # @option opts [Symbol, nil] :date_format (:short), :full
325
333
  # @option opts [String, Symbol] :lang language
326
334
  # @return [String] XML
327
335
  def to_xml(**opts, &block)
@@ -365,8 +373,8 @@ module RelatonBib
365
373
  if contributor&.any?
366
374
  hash["contributor"] = single_element_array(contributor)
367
375
  end
368
- hash["edition"] = edition if edition
369
- hash["version"] = version.to_hash if version
376
+ hash["edition"] = edition.to_hash if edition
377
+ hash["version"] = version.map &:to_hash if version.any?
370
378
  hash["revdate"] = revdate if revdate
371
379
  hash["biblionote"] = single_element_array(biblionote) if biblionote&.any?
372
380
  hash["language"] = single_element_array(language) if language&.any?
@@ -493,10 +501,10 @@ module RelatonBib
493
501
  end
494
502
 
495
503
  # If revision_date exists then returns it else returns published date or nil
496
- # @return [String, NilClass]
504
+ # @return [String, nil]
497
505
  def revdate # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
498
- @revdate ||= if version&.revision_date
499
- version.revision_date
506
+ @revdate ||= if (v = version.detect &:revision_date)
507
+ v.revision_date
500
508
  else
501
509
  date.detect { |d| d.type == "published" }&.on&.to_s
502
510
  end
@@ -515,10 +523,10 @@ module RelatonBib
515
523
  out += di.to_asciibib prefix, docidentifier.size
516
524
  end
517
525
  out += "#{pref}docnumber:: #{docnumber}\n" if docnumber
518
- out += "#{pref}edition:: #{edition}\n" if edition
526
+ out += edition.to_asciibib(prefix) if edition
519
527
  language.each { |l| out += "#{pref}language:: #{l}\n" }
520
528
  script.each { |s| out += "#{pref}script:: #{s}\n" }
521
- out += version.to_asciibib prefix if version
529
+ version.each { |v| out += v.to_asciibib prefix, version.size }
522
530
  biblionote&.each { |b| out += b.to_asciibib prefix, biblionote.size }
523
531
  out += status.to_asciibib prefix if status
524
532
  date.each { |d| out += d.to_asciibib prefix, date.size }
@@ -565,7 +573,7 @@ module RelatonBib
565
573
  item.type = bibtex_type
566
574
  item.key = id
567
575
  title.to_bibtex item
568
- item.edition = edition if edition
576
+ item.edition = edition.content if edition
569
577
  bibtex_author item
570
578
  bibtex_contributor item
571
579
  item.address = place.first.name if place.any?
@@ -719,7 +727,7 @@ module RelatonBib
719
727
  # @param opts [Hash]
720
728
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
721
729
  # @option opts [Boolean] bibdata
722
- # @option opts [Symbol, NilClass] :date_format (:short), :full
730
+ # @option opts [Symbol, nil] :date_format (:short), :full
723
731
  # @option opts [String] :lang language
724
732
  def render_xml(**opts)
725
733
  root = opts[:bibdata] ? :bibdata : :bibitem
@@ -737,8 +745,8 @@ module RelatonBib
737
745
  c.to_xml(**opts)
738
746
  end
739
747
  end
740
- builder.edition edition if edition
741
- version&.to_xml builder
748
+ edition&.to_xml builder
749
+ version.each { |v| v.to_xml builder }
742
750
  biblionote.to_xml(**opts)
743
751
  opts[:note]&.each do |n|
744
752
  builder.note(n[:text], format: "text/plain", type: n[:type])
@@ -790,7 +798,8 @@ module RelatonBib
790
798
  def render_bibxml(builder, include_keywords)
791
799
  target = link.detect { |l| l.type.casecmp("src").zero? } ||
792
800
  link.detect { |l| l.type.casecmp("doi").zero? }
793
- bxml = if docnumber&.match(/^BCP/) || docidentifier[0].id.include?("BCP")
801
+ bxml = if docnumber&.match(/^BCP/) || (docidentifier.detect(&:primary)&.id ||
802
+ docidentifier[0].id).include?("BCP")
794
803
  render_bibxml_refgroup(builder, include_keywords)
795
804
  else
796
805
  render_bibxml_ref(builder, include_keywords)
@@ -820,13 +829,17 @@ module RelatonBib
820
829
  #
821
830
  def render_bibxml_ref(builder, include_keywords)
822
831
  builder.reference(**ref_attrs) do |xml|
823
- xml.front do
824
- xml.title title[0].title.content if title.any?
825
- render_authors xml
826
- render_date xml
827
- render_workgroup xml
828
- render_keyword xml if include_keywords
829
- render_abstract xml
832
+ if title.any? || contributor.any? || date.any? || abstract.any? ||
833
+ editorialgroup&.technical_committee&.any? ||
834
+ (include_keywords && keyword.any?)
835
+ xml.front do
836
+ xml.title title[0].title.content if title.any?
837
+ render_authors xml
838
+ render_date xml
839
+ render_workgroup xml
840
+ render_keyword xml if include_keywords
841
+ render_abstract xml
842
+ end
830
843
  end
831
844
  render_seriesinfo xml
832
845
  render_format xml
@@ -12,6 +12,16 @@ module RelatonBib
12
12
  "3GPP" => "3rd Generation Partnership Project",
13
13
  }.freeze
14
14
 
15
+ #
16
+ # Parse BibXML content
17
+ #
18
+ # @param [String] bibxml content
19
+ # @param [String, nil] url source URL
20
+ # @param [Boolean] is_relation true if the content is relation item
21
+ # @param [String, nil] ver version
22
+ #
23
+ # @return [<Type>] <description>
24
+ #
15
25
  def parse(bibxml, url: nil, is_relation: false, ver: nil)
16
26
  doc = Nokogiri::XML bibxml
17
27
  fetch_rfc doc.at("/referencegroup", "/reference"), url: url, is_relation: is_relation, ver: ver
@@ -4,21 +4,24 @@ module RelatonBib
4
4
  # @return [String]
5
5
  attr_reader :id
6
6
 
7
- # @return [String, NilClass]
8
- attr_reader :type, :scope
7
+ # @return [String, nil]
8
+ attr_reader :type, :scope, :language, :script
9
9
 
10
10
  # @param type [Boolean, nil]
11
11
  attr_reader :primary
12
12
 
13
13
  # @param id [String]
14
- # @param type [String, NilClass]
15
- # @param scope [String, NilClass]
16
- # @param priority [Bolean]
17
- def initialize(id:, type: nil, scope: nil, primary: false)
18
- @id = id
19
- @type = type
20
- @scope = scope
21
- @primary = primary
14
+ # @param type [String, nil]
15
+ # @param scope [String, nil]
16
+ # @param primary [Bolean, nil]
17
+ # @param language [String, nil]
18
+ def initialize(**args)
19
+ @id = args[:id]
20
+ @type = args[:type]
21
+ @scope = args[:scope]
22
+ @primary = args[:primary]
23
+ @language = args[:language]
24
+ @script = args[:script]
22
25
  end
23
26
 
24
27
  # in docid manipulations, assume ISO as the default: id-part:year
@@ -53,7 +56,7 @@ module RelatonBib
53
56
  # @param opts [Hash]
54
57
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
55
58
  # @option opts [String] :lang language
56
- def to_xml(**opts) # rubocop:disable Metrics/AbcSize
59
+ def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
57
60
  lid = if type == "URN" && opts[:lang]
58
61
  id.sub %r{(?<=:)(?:\w{2},)*?(#{opts[:lang]})(?:,\w{2})*}, '\1'
59
62
  else id
@@ -62,14 +65,18 @@ module RelatonBib
62
65
  element[:type] = type if type
63
66
  element[:scope] = scope if scope
64
67
  element[:primary] = primary if primary
68
+ element[:language] = language if language
69
+ element[:script] = script if script
65
70
  end
66
71
 
67
72
  # @return [Hash]
68
- def to_hash
73
+ def to_hash # rubocop:disable Metrics/AbcSize
69
74
  hash = { "id" => id }
70
75
  hash["type"] = type if type
71
76
  hash["scope"] = scope if scope
72
77
  hash["primary"] = primary if primary
78
+ hash["language"] = language if language
79
+ hash["script"] = script if script
73
80
  hash
74
81
  end
75
82
 
@@ -84,6 +91,8 @@ module RelatonBib
84
91
  out += "#{pref}docid.type:: #{type}\n" if type
85
92
  out += "#{pref}docid.scope:: #{scope}\n" if scope
86
93
  out += "#{pref}docid.primary:: #{primary}\n" if primary
94
+ out += "#{pref}docid.language:: #{language}\n" if language
95
+ out += "#{pref}docid.script:: #{script}\n" if script
87
96
  out + "#{pref}docid.id:: #{id}\n"
88
97
  end
89
98
 
@@ -0,0 +1,55 @@
1
+ module RelatonBib
2
+ class Edition
3
+ # @return [String] edition
4
+ attr_reader :content
5
+
6
+ # @return [String, nil] number
7
+ attr_reader :number
8
+
9
+ #
10
+ # Initialize edition.
11
+ #
12
+ # @param [String] content edition
13
+ # @param [String, nil] number number
14
+ #
15
+ def initialize(content:, number: nil)
16
+ @content = content
17
+ @number = number
18
+ end
19
+
20
+ #
21
+ # Render edition as XML.
22
+ #
23
+ # @param [Nokogiri::XML::Builder] builder XML builder
24
+ #
25
+ def to_xml(builder)
26
+ node = builder.edition(content)
27
+ node[:number] = number if number
28
+ end
29
+
30
+ #
31
+ # Return edition as hash.
32
+ #
33
+ # @return [Hash] edition as hash.
34
+ #
35
+ def to_hash
36
+ hash = { "content" => content }
37
+ hash["number"] = number if number
38
+ hash
39
+ end
40
+
41
+ #
42
+ # Render edition as AsciiBib.
43
+ #
44
+ # @param [String] prefix prefix
45
+ #
46
+ # @return [String] edition as AsciiBib.
47
+ #
48
+ def to_asciibib(prefix = "")
49
+ pref = prefix.empty? ? "edition" : "#{prefix}.edition"
50
+ out = "#{pref}.content:: #{content}\n"
51
+ out += "#{pref}.number:: #{number}\n" if number
52
+ out
53
+ end
54
+ end
55
+ end