Sha256: 63c138e641792279c10a7ce6f159b4e2e209a38447ddbc2de817c0d33e2bf153
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'time' class FrenchPress class Post # Represents a generic post (i.e. a text post) class Generic attr_reader :file_name attr_writer :parent_blog def initialize(content, file_type = nil) title = (rand(36**9) + rand(36**10)).to_s(36) # Random title assign_variables(:@content => content, :@blog => FrenchPress.working, :@date => Time.now, :@title => title, :@file_type => file_type) derive_variables end def assign_variables(args) args.each(&method(:instance_variable_set)) # Thanks, SO end def derive_variables @file_name = @date.strftime '%Y-%m-%d' + '-' + @title @file_suffix = 'jpeg' if @file_suffix == 'jpg' @file_suffix ||= 'html' end def tags [ '---', "type: #{@type}", "date: #{@date.strftime '%Y-%m-%d %H:%M:%S'}", 'layout: post', "title: #{@title}", '---' ] end def render @content end def render_as_quote "<a href=\"#{@parent_blog[:url]}\" class=\"quote-attr\">" \ "#{@parent_blog[:host]}</a>\n" \ "<blockquote>#{render}</blockquote>" end def render_with_tags (tags << render).join("\n") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
frenchpress-0.2.1 | lib/frenchpress/post/generic.rb |
frenchpress-0.2 | lib/frenchpress/post/generic.rb |