Class: Pubid::Nist::Renderer
- Inherits:
-
Core::Renderer::Base
- Object
- Core::Renderer::Base
- Pubid::Nist::Renderer
- Defined in:
- lib/pubid/nist/renderer.rb
Instance Method Summary collapse
- #render_appendix(appendix, opts, _params) ⇒ Object
- #render_base_identifier(**opts) ⇒ Object
- #render_code(code, opts, _params) ⇒ Object
- #render_edition(edition, opts, _params) ⇒ Object
- #render_errata(errata, opts, _params) ⇒ Object
- #render_identifier(params, opts) ⇒ Object
- #render_index(index, opts, _params) ⇒ Object
- #render_insert(insert, opts, _params) ⇒ Object
- #render_part(part, opts, _params) ⇒ Object
- #render_revision(revision, opts, _params) ⇒ Object
- #render_section(section, opts, _params) ⇒ Object
- #render_serie(serie, opts, params) ⇒ Object
- #render_stage(stage, opts, _params) ⇒ Object
- #render_supplement(supplement, opts, _params) ⇒ Object
- #render_translation(translation, opts, _params) ⇒ Object
- #render_update(update, opts, _params) ⇒ Object
- #render_version(version, opts, _params) ⇒ Object
- #render_volume(volume, opts, params) ⇒ Object
Instance Method Details
#render_appendix(appendix, opts, _params) ⇒ Object
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/pubid/nist/renderer.rb', line 138 def render_appendix(appendix, opts, _params) case opts[:format] when :long " Appendix " when :abbrev " App. " when :short, :mr "app" end end |
#render_base_identifier(**opts) ⇒ Object
3 4 5 6 7 |
# File 'lib/pubid/nist/renderer.rb', line 3 def render_base_identifier(**opts) prerender(**opts) render_identifier(@prerendered_params, opts) end |
#render_code(code, opts, _params) ⇒ Object
38 39 40 |
# File 'lib/pubid/nist/renderer.rb', line 38 def render_code(code, opts, _params) (opts[:format] == :mr ? "." : " ") + code.to_s end |
#render_edition(edition, opts, _params) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pubid/nist/renderer.rb', line 42 def render_edition(edition, opts, _params) case opts[:format] when :long " Edition " when :abbrev " Ed. " when :short, :mr "e" end + edition.to_s end |
#render_errata(errata, opts, _params) ⇒ Object
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/pubid/nist/renderer.rb', line 160 def render_errata(errata, opts, _params) case opts[:format] when :long " Errata " when :abbrev " Err. " when :short, :mr "err" end end |
#render_identifier(params, opts) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pubid/nist/renderer.rb', line 9 def render_identifier(params, opts) result = "%{serie}%{stage}%{code}%{volume}%{part}%{edition}%{revision}%{version}"\ "%{supplement}%{section}%{appendix}%{errata}%{index}%{insert}%{update}"\ "%{translation}" % params if params[:addendum] && !params[:addendum].empty? case opts[:format] when :long "Addendum to #{result}" when :abbrev "Add. to #{result}" when :short "#{result} Add." when :mr "#{result}.add-1" end else result end end |
#render_index(index, opts, _params) ⇒ Object
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/pubid/nist/renderer.rb', line 171 def render_index(index, opts, _params) case opts[:format] when :long " Index " when :abbrev " Index. " when :short, :mr "indx" end end |
#render_insert(insert, opts, _params) ⇒ Object
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/pubid/nist/renderer.rb', line 182 def render_insert(insert, opts, _params) case opts[:format] when :long " Insert " when :abbrev " Ins. " when :short, :mr "ins" end end |
#render_part(part, opts, _params) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/pubid/nist/renderer.rb', line 116 def render_part(part, opts, _params) case opts[:format] when :long " Part " when :abbrev " Pt. " when :short, :mr "pt" end + part end |
#render_revision(revision, opts, _params) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pubid/nist/renderer.rb', line 53 def render_revision(revision, opts, _params) case opts[:format] when :long ", Revision " when :abbrev ", Rev. " when :short, :mr "r" end + (revision == '' ? '1' : revision).to_s end |
#render_section(section, opts, _params) ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/pubid/nist/renderer.rb', line 149 def render_section(section, opts, _params) case opts[:format] when :long " Section " when :abbrev " Sec. " when :short, :mr "sec" end + section end |
#render_serie(serie, opts, params) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/pubid/nist/renderer.rb', line 30 def render_serie(serie, opts, params) if serie.to_s(opts[:format]).include?(params[:publisher].to_s(opts[:format])) return serie.to_s(opts[:format]) end "#{params[:publisher].to_s(opts[:format])} #{serie.to_s(opts[:format])}" end |
#render_stage(stage, opts, _params) ⇒ Object
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/pubid/nist/renderer.rb', line 193 def render_stage(stage, opts, _params) case opts[:format] when :mr "." when :short "" else " " end + stage.to_s(opts[:format]) end |
#render_supplement(supplement, opts, _params) ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# File 'lib/pubid/nist/renderer.rb', line 127 def render_supplement(supplement, opts, _params) case opts[:format] when :long " Supplement " when :abbrev " Suppl. " when :short, :mr "sup" end + supplement end |
#render_translation(translation, opts, _params) ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/pubid/nist/renderer.rb', line 105 def render_translation(translation, opts, _params) case opts[:format] when :long, :abbrev " (#{translation.upcase})" when :mr ".#{translation}" when :short "(#{translation})" end end |
#render_update(update, opts, _params) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/pubid/nist/renderer.rb', line 88 def render_update(update, opts, _params) update_text = update.number.to_s update_text += "-#{update.year}" if update.year update_text += sprintf("%02d", update.month) if update.month case opts[:format] when :long " Update #{update_text}" when :abbrev " Upd. #{update_text}" when :short "/Upd#{update_text}" when :mr ".u#{update_text}" end end |
#render_version(version, opts, _params) ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pubid/nist/renderer.rb', line 64 def render_version(version, opts, _params) case opts[:format] when :long ", Version " when :abbrev ", Ver. " when :short, :mr "ver" end + version end |
#render_volume(volume, opts, params) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/pubid/nist/renderer.rb', line 75 def render_volume(volume, opts, params) case opts[:format] when :long ", Volume " when :abbrev ", Vol. " when :short params[:code] ? "v" : " v" when :mr params[:code] ? "v" : ".v" end + volume end |