Class: IsoDoc::Gb::Common
- Inherits:
-
Common
- Object
- Common
- IsoDoc::Gb::Common
- Defined in:
- lib/isodoc/gb/common.rb
Overview
A Converter implementation that generates GB output, and a document schema encapsulation of the document for validation
Instance Attribute Summary collapse
-
#meta ⇒ Object
Returns the value of attribute meta.
Instance Method Summary collapse
- #fileloc(loc) ⇒ Object
- #format_agency(agency, format, localdir) ⇒ Object
- #format_agency1(agency, format) ⇒ Object
- #format_logo(prefix, scope, _format, localdir) ⇒ Object
- #format_logo1(logo, prefix, scope, localdir) ⇒ Object
-
#initialize(options) ⇒ Common
constructor
A new instance of Common.
- #local_logo_suffix(scope) ⇒ Object
Constructor Details
#initialize(options) ⇒ Common
Returns a new instance of Common.
13 14 15 16 17 18 |
# File 'lib/isodoc/gb/common.rb', line 13 def initialize() @meta = [:meta] @standardlogoimg = [:standardlogoimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/") @standardclassimg = [:standardclassimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/") @standardissuerimg = [:standardissuerimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/") end |
Instance Attribute Details
#meta ⇒ Object
Returns the value of attribute meta.
11 12 13 |
# File 'lib/isodoc/gb/common.rb', line 11 def @meta end |
Instance Method Details
#fileloc(loc) ⇒ Object
20 21 22 |
# File 'lib/isodoc/gb/common.rb', line 20 def fileloc(loc) File.(File.join(File.dirname(__FILE__), loc)) end |
#format_agency(agency, format, localdir) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/isodoc/gb/common.rb', line 24 def format_agency(agency, format, localdir) return "<img class='logo' src='#{@standardissuerimg}' alt='#{agency.join(",")}'></img>" if @standardissuerimg return agency unless agency.is_a?(Array) if agency == ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] logo = "gb-issuer-default.gif" #FileUtils.cp fileloc(File.join('html/gb-logos', logo)), logo return "<img class='logo' src='#{fileloc(File.join('html/gb-logos', logo))}' alt='#{agency.join(",")}'></img>" end format_agency1(agency, format) end |
#format_agency1(agency, format) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/isodoc/gb/common.rb', line 35 def format_agency1(agency, format) ret = "<table>" agency.each { |a| ret += "<tr><td>#{a}</td></tr>" } ret += "</table>" ret.gsub!(/<table>/, "<table width='100%'>") if format == :word ret end |
#format_logo(prefix, scope, _format, localdir) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/isodoc/gb/common.rb', line 43 def format_logo(prefix, scope, _format, localdir) logo = @meta.standard_logo(prefix) return format_logo1(logo, prefix, scope, localdir) if @standardlogoimg return "" if %w(enterprise social-group).include? scope if logo.nil? "<span style='font-size:36pt;font-weight:bold'>#{prefix}</span>" else format_logo1(logo, prefix, scope, localdir) end end |
#format_logo1(logo, prefix, scope, localdir) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/isodoc/gb/common.rb', line 60 def format_logo1(logo, prefix, scope, localdir) local = local_logo_suffix(scope) return "<img class='logo' width='113' height='56' src='#{@standardlogoimg}' alt='#{prefix}'></img>"\ "#{local}" if @standardlogoimg logo += ".gif" #FileUtils.cp fileloc(File.join('html/gb-logos', logo)), logo #@files_to_delete << logo "<img class='logo' width='113' height='56' src='#{fileloc(File.join('html/gb-logos', logo))}' alt='#{prefix}'></img>"\ "#{local}" end |
#local_logo_suffix(scope) ⇒ Object
54 55 56 57 58 |
# File 'lib/isodoc/gb/common.rb', line 54 def local_logo_suffix(scope) return "" if scope != "local" local = @meta.get[:gblocalcode] "<span style='font-weight:bold'>#{local}</span>" end |