class IsoDoc::Gb::Common

A {Converter} implementation that generates GB output, and a document schema encapsulation of the document for validation

Attributes

meta[RW]

Public Class Methods

new(options) click to toggle source
# File lib/isodoc/gb/common.rb, line 13
def initialize(options)
  @meta = options[:meta]
  @standardlogoimg = options[:standardlogoimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/")
  @standardclassimg = options[:standardclassimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/")
  @standardissuerimg = options[:standardissuerimg]&.sub(%r{^(?=/|[A-Z]:/)}, "#{@localdir}/")
end

Public Instance Methods

fileloc(loc) click to toggle source
# File lib/isodoc/gb/common.rb, line 20
def fileloc(loc)
  File.expand_path(File.join(File.dirname(__FILE__), loc))
end
format_agency(agency, format, localdir) click to toggle source
# 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) click to toggle source
# 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_logo1(logo, prefix, scope, localdir) click to toggle source
# 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) click to toggle source
# 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