class Yome::Section
Constants
- LANG_HASH
Attributes
section[R]
Public Class Methods
new(chip)
click to toggle source
# File lib/yome/section.rb, line 5 def initialize(chip) @section = chip @texts = [] end
Public Instance Methods
add_text(chip)
click to toggle source
# File lib/yome/section.rb, line 14 def add_text(chip) @texts << chip end
priority()
click to toggle source
# File lib/yome/section.rb, line 10 def priority @section.priority end
result(parser, lang)
click to toggle source
# File lib/yome/section.rb, line 18 def result(parser, lang) <<EOS ## #{@section.content} *#{@section.path}* #{src_code(parser, @section, false, lang)} #{@texts.map { |e| src_code(parser, e, true, lang) }.join("\n")} EOS end
Private Instance Methods
detect_lang()
click to toggle source
# File lib/yome/section.rb, line 62 def detect_lang ext = File.extname(@section.path) LANG_HASH[ext] end
src_code(parser, chip, with_text, lang)
click to toggle source
# File lib/yome/section.rb, line 31 def src_code(parser, chip, with_text, lang) lang = detect_lang if lang.empty? r = [] if with_text r << chip.content end if chip.has_src? r << "" r << "```#{lang}" r << parser.file_hash[chip.path][(chip.index + 1)..(chip.end_index)].join("\n") r << "```" end r.join("\n") end