class EpubForge::Builder::Assets::Page
Attributes
dest_extension[R]
dest_filename[R]
html[R]
media_type[R]
original_file[R]
project[R]
section_id[R]
source_format[R]
title[R]
Public Class Methods
new(file, metadata, project)
click to toggle source
# File lib/epubforge/builder/assets/page.rb, line 15 def initialize file, metadata, project raise "NIL" if project.nil? @original_file = file.fwf_filepath @source_format = @original_file.ext.to_sym @metadata = metadata @project = project @dest_extension = "xhtml" @section_id = @original_file.basename_no_ext @dest_filename = "#{@section_id}.#{@dest_extension}" get_html get_title @content = "" @cover = false puts "Initialized #{file} with title [#{@title}]" end
Public Instance Methods
cover?()
click to toggle source
# File lib/epubforge/builder/assets/page.rb, line 63 def cover? @section_id == "cover" end
get_html()
click to toggle source
# File lib/epubforge/builder/assets/page.rb, line 35 def get_html @html = Utils::HtmlTranslator.translate( @original_file ) end
get_title()
click to toggle source
# File lib/epubforge/builder/assets/page.rb, line 39 def get_title html_doc = Nokogiri::HTML( @html ) h1 = html_doc.xpath("//h1").first if h1.nil? @title = @original_file.basename.to_s.split(".")[0..-2].map(&:capitalize).join(" : ") else title = h1.content @title = title.gsub(/\s*\/+\s*/, "").epf_titlecap_words end end
item_id()
click to toggle source
# File lib/epubforge/builder/assets/page.rb, line 55 def item_id cover? ? "cover" : self.link.basename end
link()
click to toggle source
# File lib/epubforge/builder/assets/page.rb, line 51 def link TEXT_DIR.join( "#{@section_id}.#{@dest_extension}" ) end