class ReVIEW::TOPBuilder

Public Instance Methods

base_block(type, lines, caption = nil) click to toggle source
# File lib/review/topbuilder.rb, line 113
def base_block(type, lines, caption = nil)
  blank
  puts "◆→開始:#{@titles[type]}←◆"
  puts "■#{compile_inline(caption)}" if caption.present?
  puts lines.join("\n")
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end
base_parablock(type, lines, caption = nil) click to toggle source
# File lib/review/topbuilder.rb, line 122
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 365
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 433
def circle_begin(_level, _label, caption)
  puts "・\t#{caption}"
end
comment(lines, comment = nil) click to toggle source
# File lib/review/topbuilder.rb, line 237
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_column_begin(type, caption) click to toggle source
# File lib/review/topbuilder.rb, line 388
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 394
def common_column_end(type)
  puts "◆→終了:#{@titles[type]}←◆"
  blank
end
compile_href(url, label) click to toggle source
# File lib/review/topbuilder.rb, line 268
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 261
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 257
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.gsub(/\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 131
def emlistnum(lines, caption = nil, _lang = nil)
  blank
  puts "◆→開始:#{@titles['emlist']}←◆"
  puts "■#{compile_inline(caption)}" if caption.present?
  lines.each_with_index do |line, i|
    puts((i + 1).to_s.rjust(2) + ": #{line}")
  end
  puts "◆→終了:#{@titles['emlist']}←◆"
  blank
end
footnote(id, str) click to toggle source
# File lib/review/topbuilder.rb, line 247
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 150
def image(lines, id, caption, metric = nil)
  metrics = parse_metric('top', metric)
  metrics = " #{metrics}" if metrics.present?
  blank
  puts "◆→開始:#{@titles['image']}←◆"
  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
  blank
  if @chapter.image(id).bound?
    puts "◆→#{@chapter.image(id).path}#{metrics}←◆"
  else
    warn "image not bound: #{id}"
    lines.each do |line|
      puts line
    end
  end
  puts "◆→終了:#{@titles['image']}←◆"
  blank
end
indepimage(_lines, id, caption = nil, metric = nil) click to toggle source
# File lib/review/topbuilder.rb, line 399
def indepimage(_lines, id, caption = nil, metric = nil)
  metrics = parse_metric('top', metric)
  metrics = " #{metrics}" if metrics.present?
  blank
  begin
    puts "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}#{metrics}←◆"
  rescue
    warn "image not bound: #{id}"
    puts "◆→画像 #{id}←◆"
  end
  puts "図 #{compile_inline(caption)}" if caption.present?
  blank
end
Also aliased as: numberlessimage
inline_ami(str) click to toggle source
# File lib/review/topbuilder.rb, line 300
def inline_ami(str)
  "#{str}◆→DTP連絡:「#{str}」に網カケ←◆"
end
inline_b(str) click to toggle source
# File lib/review/topbuilder.rb, line 308
def inline_b(str)
  "★#{str}☆"
end
Also aliased as: inline_strong
inline_balloon(str) click to toggle source
# File lib/review/topbuilder.rb, line 349
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 370
def inline_bib(id)
  %Q([#{@chapter.bibpaper(id).number}])
rescue KeyError
  error "unknown bib: #{id}"
end
inline_bou(str) click to toggle source
# File lib/review/topbuilder.rb, line 341
def inline_bou(str)
  "#{str}◆→DTP連絡:「#{str}」に傍点←◆"
end
inline_code(str) click to toggle source
# File lib/review/topbuilder.rb, line 415
def inline_code(str)
  "△#{str}☆"
end
inline_comment(str) click to toggle source
# File lib/review/topbuilder.rb, line 353
def inline_comment(str)
  if @book.config['draft']
    "◆→#{str}←◆"
  else
    ''
  end
end
inline_fn(id) click to toggle source
# File lib/review/topbuilder.rb, line 251
def inline_fn(id)
  "【注#{@chapter.footnote(id).number}】"
rescue KeyError
  error "unknown footnote: #{id}"
end
inline_hidx(str) click to toggle source
# File lib/review/topbuilder.rb, line 296
def inline_hidx(str)
  "◆→索引項目:#{str}←◆"
end
inline_hint(str) click to toggle source
# File lib/review/topbuilder.rb, line 284
def inline_hint(str)
  "◆→ヒントスタイルここから←◆#{str}◆→ヒントスタイルここまで←◆"
end
inline_i(str) click to toggle source
# File lib/review/topbuilder.rb, line 304
def inline_i(str)
  "▲#{str}☆"
end
inline_icon(id) click to toggle source
# File lib/review/topbuilder.rb, line 332
def inline_icon(id)
  begin
    "◆→画像 #{@chapter.image(id).path.sub(%r{\A\./}, '')}←◆"
  rescue
    warn "image not bound: #{id}"
    "◆→画像 #{id}←◆"
  end
end
inline_idx(str) click to toggle source
# File lib/review/topbuilder.rb, line 292
def inline_idx(str)
  "#{str}◆→索引項目:#{str}←◆"
end
inline_keytop(str) click to toggle source
# File lib/review/topbuilder.rb, line 345
def inline_keytop(str)
  "#{str}◆→キートップ#{str}←◆"
end
inline_labelref(idref) click to toggle source
# File lib/review/topbuilder.rb, line 423
def inline_labelref(idref)
  "「◆→#{idref}←◆」" # 節、項を参照
end
Also aliased as: inline_ref
inline_m(str) click to toggle source
# File lib/review/topbuilder.rb, line 361
def inline_m(str)
  %Q(◆→TeX式ここから←◆#{str}◆→TeX式ここまで←◆)
end
inline_maru(str) click to toggle source
# File lib/review/topbuilder.rb, line 288
def inline_maru(str)
  "#{str}◆→丸数字#{str}←◆"
end
inline_pageref(idref) click to toggle source
# File lib/review/topbuilder.rb, line 429
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 280
def inline_sub(str)
  "#{str}◆→DTP連絡:「#{str}」は下付き←◆"
end
inline_sup(str) click to toggle source
# File lib/review/topbuilder.rb, line 276
def inline_sup(str)
  "#{str}◆→DTP連絡:「#{str}」は上付き←◆"
end
inline_tt(str) click to toggle source
# File lib/review/topbuilder.rb, line 314
def inline_tt(str)
  "△#{str}☆"
end
inline_ttb(str) click to toggle source
# File lib/review/topbuilder.rb, line 318
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 324
def inline_tti(str)
  "▲#{str}☆◆→等幅フォントイタ←◆"
end
inline_ttibold(str) click to toggle source
# File lib/review/topbuilder.rb, line 419
def inline_ttibold(str)
  "▲#{str}☆◆→等幅フォント太字イタ←◆"
end
inline_u(str) click to toggle source
# File lib/review/topbuilder.rb, line 328
def inline_u(str)
  "@#{str}@◆→@〜@部分に下線←◆"
end
lead(lines)
Alias for: read
list_body(_id, lines, _lang) click to toggle source
# File lib/review/topbuilder.rb, line 105
def list_body(_id, lines, _lang)
  lines.each do |line|
    puts detab(line)
  end
  puts "◆→終了:#{@titles['list']}←◆"
  blank
end
list_header(id, caption, _lang) click to toggle source
# File lib/review/topbuilder.rb, line 94
def list_header(id, caption, _lang)
  blank
  puts "◆→開始:#{@titles['list']}←◆"
  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
  blank
end
listnum_body(lines, _lang) click to toggle source
# File lib/review/topbuilder.rb, line 142
def listnum_body(lines, _lang)
  lines.each_with_index do |line, i|
    puts((i + 1).to_s.rjust(2) + ": #{line}")
  end
  puts "◆→終了:#{@titles['list']}←◆"
  blank
end
noindent() click to toggle source
# File lib/review/topbuilder.rb, line 376
def noindent
  puts '◆→DTP連絡:次の1行インデントなし←◆'
end
nonum_begin(level, _label, caption) click to toggle source
# File lib/review/topbuilder.rb, line 380
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 384
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#{lines.join}"
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
# File lib/review/topbuilder.rb, line 188
def table(lines, id = nil, caption = nil)
  rows = []
  sepidx = nil
  lines.each_with_index do |line, idx|
    if /\A[\=\-]{12}/ =~ line
      # just ignore
      # error "too many table separator" if sepidx
      sepidx ||= idx
      next
    end
    rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
  end
  rows = adjust_n_cols(rows)
  error 'no rows in the table' if rows.empty?

  blank
  puts "◆→開始:#{@titles['table']}←◆"

  begin
    table_header id, caption if caption.present?
  rescue KeyError
    error "no such table: #{id}"
  end
  table_begin rows.first.size
  if sepidx
    sepidx.times do
      tr(rows.shift.map { |s| th(s) })
    end
    rows.each do |cols|
      tr(cols.map { |s| td(s) })
    end
  else
    rows.each do |cols|
      h, *cs = *cols
      tr([th(h)] + cs.map { |s| td(s) })
    end
  end
  table_end
end
table_end() click to toggle source
# File lib/review/topbuilder.rb, line 232
def table_end
  puts "◆→終了:#{@titles['table']}←◆"
  blank
end
texequation(lines, id = nil, caption = '') click to toggle source
# File lib/review/topbuilder.rb, line 173
def texequation(lines, id = nil, caption = '')
  blank
  puts "◆→開始:#{@titles['texequation']}←◆"
  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
  puts lines.join("\n")
  puts "◆→終了:#{@titles['texequation']}←◆"
  blank
end
th(str) click to toggle source
# File lib/review/topbuilder.rb, line 228
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#{lines.join}"
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