Module: Diary::Item::Output

Included in:
Page, Post
Defined in:
lib/diary/item/output.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



18
19
20
21
22
23
24
# File 'lib/diary/item/output.rb', line 18

def content
  return @content if @content

  File.open(path, 'r') do |f|
    @content ||= BlueCloth.new(f.read.split(/---\n/).slice(-1).strip).to_html
  end
end

#output(force = false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/diary/item/output.rb', line 4

def output(force = false)
  if changed? or force
    FileUtils.mkpath output_directory
    File.open(output_path, 'w+') { |f| f.puts render }
    Diary.message (force ? :force : :update), output_path, (force ? :yellow : :green)

    return true
  else
    Diary.message :identical, output_path, :yellow

    return false
  end
end