class Caramelize::Page

Attributes

author[RW]
body[RW]
id[RW]
latest[RW]
markup[RW]
message[RW]
time[RW]
title[RW]

Public Class Methods

new(page = {}) click to toggle source
# File lib/caramelize/page.rb, line 7
def initialize(page = {})
  @id =      page[:id]
  @title =   page.fetch(:title, '')
  @body =    page.fetch(:body, '')
  @syntax =  page[:markup]
  @latest =  page[:latest] || false
  @time =    page.fetch(:time, Time.now)
  @message = page.fetch(:message, '')
  @author =  page[:author]
end

Public Instance Methods

author_email() click to toggle source
# File lib/caramelize/page.rb, line 18
def author_email
  author[:email]
end
author_name() click to toggle source
# File lib/caramelize/page.rb, line 22
def author_name
  author[:name]
end
commit_message() click to toggle source
# File lib/caramelize/page.rb, line 52
def commit_message
  return "Edit in page #{title}" if message.empty?

  message
end
latest?() click to toggle source
# File lib/caramelize/page.rb, line 30
def latest?
  @latest
end
path() click to toggle source
# File lib/caramelize/page.rb, line 34
def path
  return @title unless @title.index('/')

  "#{title_pieces.first}/#{title_pieces.last.downcase}"
end
set_latest() click to toggle source
# File lib/caramelize/page.rb, line 44
def set_latest
  @latest = true
end
title_pieces() click to toggle source
# File lib/caramelize/page.rb, line 40
def title_pieces
  @title.split('/')
end
to_s() click to toggle source
# File lib/caramelize/page.rb, line 48
def to_s
  @title
end