class Caramelize::Page

Attributes

author[RW]
author_name[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]
  @author_name = page[:author_name]
end

Public Instance Methods

author_email() click to toggle source
# File lib/caramelize/page.rb, line 19
def author_email
  author.email
end
commit_message() click to toggle source
# File lib/caramelize/page.rb, line 49
def commit_message
  return "Edit in page #{title}" if message.empty?
  message
end
latest?() click to toggle source
# File lib/caramelize/page.rb, line 32
def latest?
  @latest
end
path() click to toggle source
# File lib/caramelize/page.rb, line 36
def path
  return @title unless @title.index('/')
  @title.split('/').first + '/' + @title.split('/').last.downcase
end
set_latest() click to toggle source
# File lib/caramelize/page.rb, line 41
def set_latest
  @latest = true
end
to_s() click to toggle source
# File lib/caramelize/page.rb, line 45
def to_s
  @title
end