class ReVIEW::TOPBuilder

Public Instance Methods

base_block(type, lines, caption = nil) click to toggle source
# File lib/review/topbuilder.rb, line 128
def base_block(type, lines, caption = nil)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  if caption_top?('list') && caption.present?
    puts "■#{compile_inline(caption)}"
  end
  puts lines.join("\n")
  if !caption_top?('list') && caption.present?
    puts "■#{compile_inline(caption)}"
  end
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end
base_parablock(type, lines, caption = nil) click to toggle source
# File lib/review/topbuilder.rb, line 142
def base_parablock(type, lines, caption = nil)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts "■#{compile_inline(caption)}" if caption.present?
  puts split_paragraph(lines).join("\n")
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end
bibpaper_header(id, caption) click to toggle source
# File lib/review/topbuilder.rb, line 438
def bibpaper_header(id, caption)
  print "[#{@chapter.bibpaper(id).number}]"
  puts " #{compile_inline(caption)}"
end
circle_begin(_level, _label, caption) click to toggle source
# File lib/review/topbuilder.rb, line 537
def circle_begin(_level, _label, caption)
  puts "・\t#{caption}"
end
comment(lines, comment = nil) click to toggle source
# File lib/review/topbuilder.rb, line 272
def comment(lines, comment = nil)
  return unless @book.config['draft']

  lines ||= []
  unless comment.blank?
    lines.unshift(comment)
  end
  str = lines.join("\n")
  puts "◆→#{str}←◆"
end
common_block_begin(type, _level, _label, caption = nil) click to toggle source
# File lib/review/topbuilder.rb, line 472
def common_block_begin(type, _level, _label, caption = nil)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts '■' + compile_inline(caption) if caption.present?
end
common_block_end(type, _level) click to toggle source
# File lib/review/topbuilder.rb, line 478
def common_block_end(type, _level)
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end
common_column_begin(type, caption) click to toggle source
# File lib/review/topbuilder.rb, line 461
def common_column_begin(type, caption)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts "■#{compile_inline(caption)}"
end
common_column_end(type) click to toggle source
# File lib/review/topbuilder.rb, line 467
def common_column_end(type)
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end
compile_href(url, label) click to toggle source
# File lib/review/topbuilder.rb, line 322
def compile_href(url, label)
  if label
    "#{label}(△#{url}☆)"
  else
    "△#{url}☆"
  end
end
compile_kw(word, alt) click to toggle source
# File lib/review/topbuilder.rb, line 315
def compile_kw(word, alt)
  if alt
  then "★#{word}☆(#{alt.strip})"
  else "★#{word}☆"
  end
end
compile_ruby(base, ruby) click to toggle source
# File lib/review/topbuilder.rb, line 311
def compile_ruby(base, ruby)
  "#{base}◆→DTP連絡:「#{base}」に「#{ruby}」とルビ←◆"
end
dd(lines) click to toggle source
# File lib/review/topbuilder.rb, line 79
def dd(lines)
  split_paragraph(lines).each do |paragraph|
    puts "\t#{paragraph.delete("\n")}"
  end
end
dt(line) click to toggle source
# File lib/review/topbuilder.rb, line 75
def dt(line)
  puts "★#{line}☆"
end
emlistnum(lines, caption = nil, _lang = nil) click to toggle source
# File lib/review/topbuilder.rb, line 151
def emlistnum(lines, caption = nil, _lang = nil)
  blank
  puts "◆→開始:#{@titles['emlist']}←◆"
  if caption_top?('list') && caption.present?
    puts "■#{compile_inline(caption)}"
  end
  lines.each_with_index do |line, i|
    puts((i + 1).to_s.rjust(2) + ": #{line}")
  end
  if !caption_top?('list') && caption.present?
    puts "■#{compile_inline(caption)}"
  end
  puts "◆→終了:#{@titles['emlist']}←◆"
  blank
end
endnote_begin() click to toggle source
# File lib/review/topbuilder.rb, line 299
def endnote_begin
  puts '◆→開始:後注←◆'
end
endnote_end() click to toggle source
# File lib/review/topbuilder.rb, line 303
def endnote_end
  puts '◆→終了:後注←◆'
end
endnote_item(id) click to toggle source
# File lib/review/topbuilder.rb, line 307
def endnote_item(id)
  puts "【後注#{@chapter.endnote(id).number}】#{compile_inline(@chapter.endnote(id).content)}"
end
footnote(id, str) click to toggle source
# File lib/review/topbuilder.rb, line 283
def footnote(id, str)
  puts "【注#{@chapter.footnote(id).number}】#{compile_inline(str)}"
end
headline(level, _label, caption) click to toggle source
# File lib/review/topbuilder.rb, line 62
def headline(level, _label, caption)
  prefix, _anchor = headline_prefix(level)
  puts %Q(■H#{level}■#{prefix}#{compile_inline(caption)})
end
image(lines, id, caption, metric = nil) click to toggle source
# File lib/review/topbuilder.rb, line 193
def image(lines, id, caption, metric = nil)
  metrics = parse_metric('top', metric)
  metrics = " #{metrics}" if metrics.present?
  blank
  puts "◆→開始:#{@titles['image']}←◆"
  if caption_top?('image')
    image_header(id, caption)
    blank
  end
  if @chapter.image_bound?(id)
    puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
  else
    warn "image not bound: #{id}", location: location
    lines.each do |line|
      puts line
    end
  end
  unless caption_top?('image')
    blank
    image_header(id, caption)
  end
  puts "◆→終了:#{@titles['image']}←◆"
  blank
end
image_header(id, caption) click to toggle source
# File lib/review/topbuilder.rb, line 218
def image_header(id, caption)
  if get_chap
    puts "#{I18n.t('image')}#{I18n.t('format_number', [get_chap, @chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
  else
    puts "#{I18n.t('image')}#{I18n.t('format_number_without_chapter', [@chapter.image(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
  end
end
indepimage(_lines, id, caption = nil, metric = nil) click to toggle source
# File lib/review/topbuilder.rb, line 498
def indepimage(_lines, id, caption = nil, metric = nil)
  metrics = parse_metric('top', metric)
  metrics = " #{metrics}" if metrics.present?
  blank
  if caption_top?('image') && caption.present?
    puts "図 #{compile_inline(caption)}"
  end
  begin
    puts "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}#{metrics}←◆"
  rescue
    warn "image not bound: #{id}", location: location
    puts "◆→画像 #{id}←◆"
  end
  if !caption_top?('image') && caption.present?
    puts "図 #{compile_inline(caption)}"
  end
  blank
end
Also aliased as: numberlessimage
inline_ami(str) click to toggle source
# File lib/review/topbuilder.rb, line 354
def inline_ami(str)
  "#{str}◆→DTP連絡:「#{str}」に網カケ←◆"
end
inline_b(str) click to toggle source
# File lib/review/topbuilder.rb, line 362
def inline_b(str)
  "★#{str}☆"
end
Also aliased as: inline_strong
inline_balloon(str) click to toggle source
# File lib/review/topbuilder.rb, line 415
def inline_balloon(str)
  %Q(\t←#{str.gsub(/@maru\[(\d+)\]/, inline_maru('\1'))})
end
inline_bib(id) click to toggle source
# File lib/review/topbuilder.rb, line 443
def inline_bib(id)
  %Q([#{@chapter.bibpaper(id).number}])
rescue KeyError
  app_error "unknown bib: #{id}"
end
inline_bou(str) click to toggle source
# File lib/review/topbuilder.rb, line 407
def inline_bou(str)
  "#{str}◆→DTP連絡:「#{str}」に傍点←◆"
end
inline_code(str) click to toggle source
# File lib/review/topbuilder.rb, line 519
def inline_code(str)
  "△#{str}☆"
end
inline_comment(str) click to toggle source
# File lib/review/topbuilder.rb, line 419
def inline_comment(str)
  if @book.config['draft']
    "◆→#{str}←◆"
  else
    ''
  end
end
inline_del(str) click to toggle source
# File lib/review/topbuilder.rb, line 390
def inline_del(str)
  "◆→開始:削除表現←◆#{str}◆→終了:削除表現←◆"
end
inline_endnote(id) click to toggle source
# File lib/review/topbuilder.rb, line 293
def inline_endnote(id)
  "【後注#{@chapter.endnote(id).number}】"
rescue KeyError
  app_error "unknown endnote: #{id}"
end
inline_fn(id) click to toggle source
# File lib/review/topbuilder.rb, line 287
def inline_fn(id)
  "【注#{@chapter.footnote(id).number}】"
rescue KeyError
  app_error "unknown footnote: #{id}"
end
inline_hidx(str) click to toggle source
# File lib/review/topbuilder.rb, line 350
def inline_hidx(str)
  "◆→索引項目:#{str}←◆"
end
inline_hint(str) click to toggle source
# File lib/review/topbuilder.rb, line 338
def inline_hint(str)
  "◆→ヒントスタイルここから←◆#{str}◆→ヒントスタイルここまで←◆"
end
inline_i(str) click to toggle source
# File lib/review/topbuilder.rb, line 358
def inline_i(str)
  "▲#{str}☆"
end
inline_icon(id) click to toggle source
# File lib/review/topbuilder.rb, line 398
def inline_icon(id)
  begin
    "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
  rescue
    warn "image not bound: #{id}", location: location
    "◆→画像 #{id}←◆"
  end
end
inline_idx(str) click to toggle source
# File lib/review/topbuilder.rb, line 346
def inline_idx(str)
  "#{str}◆→索引項目:#{str}←◆"
end
inline_ins(str) click to toggle source
# File lib/review/topbuilder.rb, line 386
def inline_ins(str)
  "◆→開始:挿入表現←◆#{str}◆→終了:挿入表現←◆"
end
inline_keytop(str) click to toggle source
# File lib/review/topbuilder.rb, line 411
def inline_keytop(str)
  "#{str}◆→キートップ#{str}←◆"
end
inline_labelref(idref) click to toggle source
# File lib/review/topbuilder.rb, line 527
def inline_labelref(idref)
  "「◆→#{idref}←◆」" # 節、項を参照
end
Also aliased as: inline_ref
inline_m(str) click to toggle source
# File lib/review/topbuilder.rb, line 427
def inline_m(str)
  if @book.config['math_format'] == 'imgmath'
    math_str = '$' + str + '$'
    key = Digest::SHA256.hexdigest(str)
    img_path = @img_math.defer_math_image(math_str, key)
    %Q(◆→TeX式ここから←◆◆→math:#{File.basename(img_path)}←◆◆→TeX式ここまで←◆)
  else
    %Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
  end
end
inline_maru(str) click to toggle source
# File lib/review/topbuilder.rb, line 342
def inline_maru(str)
  "#{str}◆→丸数字#{str}←◆"
end
inline_pageref(idref) click to toggle source
# File lib/review/topbuilder.rb, line 533
def inline_pageref(idref)
  "●ページ◆→#{idref}←◆" # ページ番号を参照
end
inline_ref(idref)
Alias for: inline_labelref
inline_strong(str)
Alias for: inline_b
inline_sub(str) click to toggle source
# File lib/review/topbuilder.rb, line 334
def inline_sub(str)
  "#{str}◆→DTP連絡:「#{str}」は下付き←◆"
end
inline_sup(str) click to toggle source
# File lib/review/topbuilder.rb, line 330
def inline_sup(str)
  "#{str}◆→DTP連絡:「#{str}」は上付き←◆"
end
inline_tcy(str) click to toggle source
# File lib/review/topbuilder.rb, line 394
def inline_tcy(str)
  "◆→開始:回転←◆#{str}◆→終了:縦回転←◆"
end
inline_tt(str) click to toggle source
# File lib/review/topbuilder.rb, line 368
def inline_tt(str)
  "△#{str}☆"
end
inline_ttb(str) click to toggle source
# File lib/review/topbuilder.rb, line 372
def inline_ttb(str)
  "★#{str}☆◆→等幅フォント太字←◆"
end
Also aliased as: inline_ttbold
inline_ttbold(str)
Alias for: inline_ttb
inline_tti(str) click to toggle source
# File lib/review/topbuilder.rb, line 378
def inline_tti(str)
  "▲#{str}☆◆→等幅フォントイタ←◆"
end
inline_ttibold(str) click to toggle source
# File lib/review/topbuilder.rb, line 523
def inline_ttibold(str)
  "▲#{str}☆◆→等幅フォント太字イタ←◆"
end
inline_u(str) click to toggle source
# File lib/review/topbuilder.rb, line 382
def inline_u(str)
  "@#{str}@◆→@〜@部分に下線←◆"
end
lead(lines)
Alias for: read
list(lines, id, caption, lang = nil) click to toggle source
# File lib/review/topbuilder.rb, line 94
def list(lines, id, caption, lang = nil)
  blank
  puts "◆→開始:#{@titles['list']}←◆"
  begin
    if caption_top?('list')
      list_header(id, caption, lang)
      blank
    end
    list_body(id, lines, lang)
    unless caption_top?('list')
      blank
      list_header(id, caption, lang)
    end
  rescue KeyError
    app_error "no such list: #{id}"
  end
  puts "◆→終了:#{@titles['list']}←◆"
  blank
end
list_body(_id, lines, _lang) click to toggle source
# File lib/review/topbuilder.rb, line 122
def list_body(_id, lines, _lang)
  lines.each do |line|
    puts detab(line)
  end
end
list_header(id, caption, _lang) click to toggle source
# File lib/review/topbuilder.rb, line 114
def list_header(id, caption, _lang)
  if get_chap
    puts %Q(#{I18n.t('list')}#{I18n.t('format_number', [get_chap, @chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
  else
    puts %Q(#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)})
  end
end
listnum(lines, id, caption, lang = nil) click to toggle source
# File lib/review/topbuilder.rb, line 167
def listnum(lines, id, caption, lang = nil)
  blank
  puts "◆→開始:#{@titles['list']}←◆"
  begin
    if caption_top?('list') && caption.present?
      list_header(id, caption, lang)
      blank
    end
    listnum_body(lines, lang)
    if !caption_top?('list') && caption.present?
      blank
      list_header(id, caption, lang)
    end
  rescue KeyError
    app_error "no such list: #{id}"
  end
  puts "◆→終了:#{@titles['list']}←◆"
  blank
end
listnum_body(lines, _lang) click to toggle source
# File lib/review/topbuilder.rb, line 187
def listnum_body(lines, _lang)
  lines.each_with_index do |line, i|
    puts((i + 1).to_s.rjust(2) + ": #{line}")
  end
end
noindent() click to toggle source
# File lib/review/topbuilder.rb, line 449
def noindent
  puts '◆→DTP連絡:次の1行インデントなし←◆'
end
nonum_begin(level, _label, caption) click to toggle source
# File lib/review/topbuilder.rb, line 453
def nonum_begin(level, _label, caption)
  puts "■H#{level}■#{compile_inline(caption)}"
end
notoc_begin(level, _label, caption) click to toggle source
# File lib/review/topbuilder.rb, line 457
def notoc_begin(level, _label, caption)
  puts "■H#{level}■#{compile_inline(caption)}◆→DTP連絡:目次に掲載しない←◆"
end
numberlessimage(_lines, id, caption = nil, metric = nil)
Alias for: indepimage
ol_item(lines, num) click to toggle source
# File lib/review/topbuilder.rb, line 71
def ol_item(lines, num)
  puts "#{num}\t#{join_lines_to_paragraph(lines)}"
end
read(lines) click to toggle source
# File lib/review/topbuilder.rb, line 85
def read(lines)
  puts "◆→開始:#{@titles['lead']}←◆"
  puts split_paragraph(lines).join("\n")
  puts "◆→終了:#{@titles['lead']}←◆"
  blank
end
Also aliased as: lead
table(lines, id = nil, caption = nil) click to toggle source
Calls superclass method ReVIEW::PLAINTEXTBuilder#table
# File lib/review/topbuilder.rb, line 257
def table(lines, id = nil, caption = nil)
  blank
  puts "◆→開始:#{@titles['table']}←◆"
  super(lines, id, caption, true)
  puts "◆→終了:#{@titles['table']}←◆"
  blank
end
table_end() click to toggle source
# File lib/review/topbuilder.rb, line 269
def table_end
end
texequation(lines, id = nil, caption = '') click to toggle source
# File lib/review/topbuilder.rb, line 226
def texequation(lines, id = nil, caption = '')
  blank
  puts "◆→開始:#{@titles['texequation']}←◆"
  texequation_header(id, caption) if caption_top?('equation')

  if @book.config['math_format'] == 'imgmath'
    fontsize = @book.config['imgmath_options']['fontsize'].to_f
    lineheight = @book.config['imgmath_options']['lineheight'].to_f
    math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{lines.join("\n")}\n\\end{equation*}\n"
    key = Digest::SHA256.hexdigest(math_str)
    img_path = @img_math.defer_math_image(math_str, key)
    puts "◆→math:#{File.basename(img_path)}←◆"
  else
    puts lines.join("\n")
  end

  texequation_header(id, caption) unless caption_top?('equation')
  puts "◆→終了:#{@titles['texequation']}←◆"
  blank
end
texequation_header(id, caption) click to toggle source
# File lib/review/topbuilder.rb, line 247
def texequation_header(id, caption)
  if id
    if get_chap
      puts "#{I18n.t('equation')}#{I18n.t('format_number', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
    else
      puts "#{I18n.t('equation')}#{I18n.t('format_number_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}"
    end
  end
end
th(str) click to toggle source
# File lib/review/topbuilder.rb, line 265
def th(str)
  "★#{str}☆"
end
ul_item(lines) click to toggle source
# File lib/review/topbuilder.rb, line 67
def ul_item(lines)
  puts "●\t#{join_lines_to_paragraph(lines)}"
end

Private Instance Methods

builder_init_file() click to toggle source
# File lib/review/topbuilder.rb, line 13
def builder_init_file
  super

  @titles = {
    'emlist' => 'インラインリスト',
    'cmd' => 'コマンド',
    'quote' => '引用',
    'centering' => '中央揃え',
    'flushright' => '右寄せ',
    'note' => 'ノート',
    'memo' => 'メモ',
    'important' => '重要',
    'info' => '情報',
    'planning' => 'プランニング',
    'shoot' => 'トラブルシュート',
    'term' => '用語解説',
    'notice' => '注意',
    'caution' => '警告',
    'warning' => '危険',
    'point' => 'ここがポイント',
    'reference' => '参考',
    'link' => 'リンク',
    'best' => 'ベストプラクティス',
    'practice' => '練習問題',
    'security' => 'セキュリティ',
    'expert' => 'エキスパートに訊け',
    'tip' => 'TIP',
    'box' => '書式',
    'insn' => '書式',
    'column' => 'コラム',
    'xcolumn' => 'コラムパターン2',
    'world' => 'Worldコラム',
    'hood' => 'Under The Hoodコラム',
    'edition' => 'Editionコラム',
    'insideout' => 'InSideOutコラム',
    'ref' => '参照',
    'sup' => '補足',
    'read' => 'リード',
    'lead' => 'リード',
    'list' => 'リスト',
    'image' => '図',
    'texequation' => 'TeX式',
    'table' => '表',
    'bpo' => 'bpo',
    'source' => 'ソースコードリスト'
  }
end