class Telegraph::Parser::Formats::Html

Public Instance Methods

build_content() click to toggle source
# File lib/telegraph/parser/formats/html.rb, line 9
        def build_content
          @content = <<-HTML.strip
            <html>
              <head>
                <meta charset="UTF-8">
                <title>#{@article.title}</title>
              </head>

              <body>
                <h1>
                  #{@article.title}
                  <small>#{@article.author}</small>
                </h1>

                <div>
                  #{@article.content}
                </div>
              </body>
            </html>
          HTML
        end
process!() click to toggle source
# File lib/telegraph/parser/formats/html.rb, line 5
def process!
  build_content
end
save(destination) click to toggle source
Calls superclass method Telegraph::Parser::Formats::Format#save
# File lib/telegraph/parser/formats/html.rb, line 31
def save(destination)
  super
  
  @article.images.each do |path, image|
    ensure_path_exists(destination, path)

    File.open("#{destination}#{path}", 'wb') do |f|
      f.write(image)
    end
  end

  true
end

Protected Instance Methods

ensure_path_exists(destination, path) click to toggle source
# File lib/telegraph/parser/formats/html.rb, line 51
def ensure_path_exists(destination, path)
  dir_seg = File.dirname("#{destination}#{path}")
  FileUtils.mkdir_p(dir_seg)
end
filename() click to toggle source
# File lib/telegraph/parser/formats/html.rb, line 47
def filename
  "#{@article.title}.html"
end