Class: Pubid::Ieee::Renderer::Base
- Inherits:
-
Core::Renderer::Base
- Object
- Core::Renderer::Base
- Pubid::Ieee::Renderer::Base
- Defined in:
- lib/pubid/ieee/renderer/base.rb
Instance Method Summary collapse
- #render_adoption(adoption, opts, _params) ⇒ Object
- #render_adoption_year(adoption_year, _opts, _params) ⇒ Object
- #render_alternative(alternative, opts, params) ⇒ Object
- #render_amendment(amendment, _opts, _params) ⇒ Object
- #render_corrigendum(corrigendum, _opts, params) ⇒ Object
- #render_corrigendum_comment(corrigendum_comment, _opts, params) ⇒ Object
- #render_day(day, _opts, params) ⇒ Object
- #render_draft(draft, _opts, params) ⇒ Object
- #render_draft_status(draft_status, opts, _params) ⇒ Object
- #render_edition(edition, _opts, _params) ⇒ Object
- #render_identifier(params) ⇒ Object
- #render_includes(includes, _opts, _params) ⇒ Object
- #render_incorporates(incorporates, _opts, _params) ⇒ Object
- #render_iso_amendment(iso_amendment, _opts, _params) ⇒ Object
- #render_month(month, _opts, params) ⇒ Object
- #render_number(number, _opts, _params) ⇒ Object
- #render_part(part, _opts, _params) ⇒ Object
- #render_publisher(publisher, opts, params) ⇒ Object
- #render_reaffirmed(reaffirmed, _opts, params) ⇒ Object
- #render_redline(_redline, _opts, _params) ⇒ Object
- #render_revision(revision, _opts, _params) ⇒ Object
- #render_stage(stage, _opts, _params) ⇒ Object
- #render_supersedes(supersedes, _opts, _params) ⇒ Object
- #render_supplement(supplement, _opts, _params) ⇒ Object
- #render_type(type, opts, params) ⇒ Object
- #render_year(year, _opts, params) ⇒ Object
Instance Method Details
#render_adoption(adoption, opts, _params) ⇒ Object
212 213 214 |
# File 'lib/pubid/ieee/renderer/base.rb', line 212 def render_adoption(adoption, _opts, _params) adoption end |
#render_adoption_year(adoption_year, _opts, _params) ⇒ Object
206 207 208 209 210 |
# File 'lib/pubid/ieee/renderer/base.rb', line 206 def render_adoption_year(adoption_year, _opts, _params) adoption_id = dup adoption_id.year = adoption_year " (Adoption of #{adoption_id.identifier})" end |
#render_alternative(alternative, opts, params) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/pubid/ieee/renderer/base.rb', line 113 def render_alternative(alternative, opts, params) # An ISO-led co-publication has no IEEE number of its own — its IEEE # designation is this alternative, so the trademark belongs on that # number rather than on the ISO one. with_trademark = opts[:with_trademark] && !params[:number] # `annotated` is deliberately not propagated — the nested alternative was # never annotated before, and this must not change plain rendering. alternatives = (alternative.is_a?(Array) ? alternative : [alternative]).map do |a| Pubid::Ieee::Identifier::Base .new(**Pubid::Ieee::Identifier.convert_parser_parameters(**a)) .to_s(with_trademark: with_trademark || false) end " (#{alternatives.join(', ')})" end |
#render_amendment(amendment, _opts, _params) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/pubid/ieee/renderer/base.rb', line 159 def render_amendment(amendment, _opts, _params) return " (Amendment to #{amendment})" unless amendment.is_a?(Array) result = " (Amendment to #{amendment.first} as amended by " result += if amendment.length > 2 "#{amendment[1..-2].map(&:to_s).join(', ')}, and #{amendment[-1]}" else amendment.last.to_s end "#{result})" end |
#render_corrigendum(corrigendum, _opts, params) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/pubid/ieee/renderer/base.rb', line 172 def render_corrigendum(corrigendum, _opts, params) # if corrigendum.nil? # (params[:year] && corrigendum_comment && "/Cor 1-#{params[:year]}") || "" # else if corrigendum[:year] "/Cor #{corrigendum[:version]}-#{corrigendum[:year]}" else "/Cor #{corrigendum[:version]}" end # end end |
#render_corrigendum_comment(corrigendum_comment, _opts, params) ⇒ Object
62 63 64 |
# File 'lib/pubid/ieee/renderer/base.rb', line 62 def render_corrigendum_comment(corrigendum_comment, _opts, params) "/Cor 1-#{params[:year]}" if params[:year] end |
#render_day(day, _opts, params) ⇒ Object
50 51 52 53 54 |
# File 'lib/pubid/ieee/renderer/base.rb', line 50 def render_day(day, _opts, params) # month = Date.parse(params[:month]).month # " %s-%s-%02d" % [params[:year], month, day] " #{day}" end |
#render_draft(draft, _opts, params) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/pubid/ieee/renderer/base.rb', line 130 def render_draft(draft, _opts, params) draft = Pubid::Ieee::Identifier.merge_parameters(draft) if draft.is_a?(Array) result = if draft[:version].is_a?(Array) "/D#{draft[:version].join('D')}" else "/#{draft[:version].to_s.match?(/^\d/) ? 'D' : ''}#{draft[:version]}" end result += "#{params[:iteration]}" if params[:iteration] result += ".#{draft[:revision]}" if draft[:revision] # result += ", #{draft[:month]}" if draft[:month] # result += " #{draft[:day]}," if draft[:day] # result += " #{draft[:year]}" if draft[:year] result end |
#render_draft_status(draft_status, opts, _params) ⇒ Object
146 147 148 |
# File 'lib/pubid/ieee/renderer/base.rb', line 146 def render_draft_status(draft_status, opts, _params) " #{draft_status}" if opts[:format] == :full end |
#render_edition(edition, _opts, _params) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/pubid/ieee/renderer/base.rb', line 89 def render_edition(edition, _opts, _params) edition == "First" ? " Edition 1.0" : " Edition #{edition}" # result = "" # if edition[:version] # result += # end # if edition[:year] # result += if edition[:version] # " #{edition[:year]}" # else # " #{edition[:year]} Edition" # end # end # # if edition[:month] # month = edition[:month] # month = Date.parse(edition[:month]).month if month.to_i.zero? # result += "-#{sprintf('%02d', month)}" # end # result += "-#{edition[:day]}" if edition[:day] # result end |
#render_identifier(params) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pubid/ieee/renderer/base.rb', line 3 def render_identifier(params) # %{trademark} sits immediately after the number (and its part/subpart): # IEEE attaches the mark to the standard number, before the year, the # draft, the corrigendum and every other suffix — "IEEE Std 802.3®-2018". if params[:iso_identifier].to_s != "" && params[:number] != "" " (%{publisher}%{stage}%{draft_status}%{type}%{number}%{iteration}%{part}%{subpart}%{trademark}%{month}%{year}%{corrigendum_comment}"\ "%{corrigendum}%{draft}%{edition})%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\ "%{revision}%{iso_amendment}%{amendment}%{edition}%{includes}%{redline}%{adoption}" % params else if params[:day].empty? && params[:month].empty? # if only year - edition and draft after year "%{publisher}%{draft_status}%{type}%{number}%{part}%{subpart}%{trademark}%{stage}"\ "%{year}%{edition}%{corrigendum_comment}%{corrigendum}%{draft}%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\ "%{revision}%{iso_amendment}%{amendment}%{includes}%{redline}%{adoption}" % params else # if year and month - edition and draft before "%{publisher}%{draft_status}%{type}%{number}%{part}%{subpart}%{trademark}%{edition}%{stage}"\ "%{corrigendum_comment}%{corrigendum}%{draft}%{month}%{day}%{year}%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\ "%{revision}%{iso_amendment}%{amendment}%{includes}%{redline}%{adoption}" % params end end end |
#render_includes(includes, _opts, _params) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/pubid/ieee/renderer/base.rb', line 81 def render_includes(includes, _opts, _params) if includes.is_a?(Hash) && includes[:supplement] return " (Includes Supplement #{includes[:supplement]})" end " (Includes #{includes})" end |
#render_incorporates(incorporates, _opts, _params) ⇒ Object
198 199 200 |
# File 'lib/pubid/ieee/renderer/base.rb', line 198 def render_incorporates(incorporates, _opts, _params) " (Incorporates #{incorporates.join(', and ')})" end |
#render_iso_amendment(iso_amendment, _opts, _params) ⇒ Object
216 217 218 219 |
# File 'lib/pubid/ieee/renderer/base.rb', line 216 def render_iso_amendment(iso_amendment, _opts, _params) "/Amd#{iso_amendment[:version]}" + (iso_amendment[:year] ? "-#{iso_amendment[:year]}" : "") end |
#render_month(month, _opts, params) ⇒ Object
56 57 58 59 60 |
# File 'lib/pubid/ieee/renderer/base.rb', line 56 def render_month(month, _opts, params) # return if params[:day] ", #{Date::MONTHNAMES[month]}" end |
#render_number(number, _opts, _params) ⇒ Object
26 27 28 |
# File 'lib/pubid/ieee/renderer/base.rb', line 26 def render_number(number, _opts, _params) " #{number}" end |
#render_part(part, _opts, _params) ⇒ Object
46 47 48 |
# File 'lib/pubid/ieee/renderer/base.rb', line 46 def render_part(part, _opts, _params) (part =~ /^[-.]/ ? "" : "-") + part end |
#render_publisher(publisher, opts, params) ⇒ Object
30 31 32 33 |
# File 'lib/pubid/ieee/renderer/base.rb', line 30 def render_publisher(publisher, opts, params) # don't render publisher if no number assigned super if params[:number] end |
#render_reaffirmed(reaffirmed, _opts, params) ⇒ Object
192 193 194 195 196 |
# File 'lib/pubid/ieee/renderer/base.rb', line 192 def render_reaffirmed(reaffirmed, _opts, params) return " (Reaffirmed #{params[:year]})" if reaffirmed.key?(:reaffirmation_of) " (Reaffirmed #{reaffirmed[:year]})" if reaffirmed[:year] end |
#render_redline(_redline, _opts, _params) ⇒ Object
154 155 156 |
# File 'lib/pubid/ieee/renderer/base.rb', line 154 def render_redline(_redline, _opts, _params) " - Redline" end |
#render_revision(revision, _opts, _params) ⇒ Object
150 151 152 |
# File 'lib/pubid/ieee/renderer/base.rb', line 150 def render_revision(revision, _opts, _params) " (Revision of #{revision.join(' and ')})" if revision end |
#render_stage(stage, _opts, _params) ⇒ Object
225 226 227 |
# File 'lib/pubid/ieee/renderer/base.rb', line 225 def render_stage(stage, _opts, _params) "/#{stage}" end |
#render_supersedes(supersedes, _opts, _params) ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/pubid/ieee/renderer/base.rb', line 184 def render_supersedes(supersedes, _opts, _params) if supersedes.length > 2 " (Supersedes #{supersedes.join(', ')})" else " (Supersedes #{supersedes.join(' and ')})" end end |
#render_supplement(supplement, _opts, _params) ⇒ Object
202 203 204 |
# File 'lib/pubid/ieee/renderer/base.rb', line 202 def render_supplement(supplement, _opts, _params) " (Supplement to #{supplement})" if supplement end |
#render_type(type, opts, params) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pubid/ieee/renderer/base.rb', line 35 def render_type(type, opts, params) result = if params[:publisher] == "IEEE" || (params[:copublisher].is_a?(Array) && params[:copublisher].include?("IEEE") || params[:copublisher] == "IEEE") type.to_s(opts[:format]) else type.to_s(:alternative) end " #{result}" unless result.empty? end |
#render_year(year, _opts, params) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pubid/ieee/renderer/base.rb', line 66 def render_year(year, _opts, params) # return if params[:day] # add comma when day appears before year return (params[:day] ? "," : "") + " #{year}" if params[:month] if params[:corrigendum_comment] "-#{params[:corrigendum_comment].year}" elsif params[:reaffirmed] && params[:reaffirmed].key?(:reaffirmation_of) "-#{params[:reaffirmed][:reaffirmation_of].year}" else "-#{year}" end end |