Sha256: 23e2f06e8310e2120d9b7f5cd0002ac9734e4067a1e8c477076e5c95898e0ba0

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

module Caramelize
  class Page

    attr_accessor :title, :body, :id, :markup, :latest, :time, :message,
                  :author, :author_name

    def initialize(page={})
      @id =      page[:id]
      @title =   page[:title] || ""
      @body =    page[:body] || ""
      @syntax =  page[:markup]
      @latest =  page[:latest] || false
      @time =    page[:time] || Time.now
      @message = page[:message] || ""
      @author =  page[:author]
      @author_name = page[:author_name]
    end

    def author_email
      author.email
    end

    def author_name
      author.name
    end

    def author
      @author ||= OpenStruct.new(name: @author_name || "Caramelize",
                             email: "mail@example.com")
    end

    def latest?
      @latest
    end

    def set_latest
      @latest = true
    end

    def to_s
      @title
    end

    def commit_message
      return "Edit in page #{title}" if message.empty?
      message
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caramelize-1.0.0 lib/caramelize/page.rb
caramelize-0.4.0 lib/caramelize/page.rb