Class: FrenchPress::Post::Generic
- Inherits:
-
Object
- Object
- FrenchPress::Post::Generic
show all
- Defined in:
- lib/frenchpress/post/generic.rb
Overview
Represents a generic post (i.e. a text post)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(content, file_type = nil) ⇒ Generic
Returns a new instance of Generic.
10
11
12
13
14
15
16
17
18
|
# File 'lib/frenchpress/post/generic.rb', line 10
def initialize(content, file_type = nil)
title = (rand(36**9) + rand(36**10)).to_s(36) assign_variables(:@content => content,
:@blog => FrenchPress.working,
:@date => Time.now,
:@title => title,
:@file_type => file_type)
derive_variables
end
|
Instance Attribute Details
#file_name ⇒ Object
Returns the value of attribute file_name.
7
8
9
|
# File 'lib/frenchpress/post/generic.rb', line 7
def file_name
@file_name
end
|
#parent_blog=(value) ⇒ Object
Sets the attribute parent_blog
8
9
10
|
# File 'lib/frenchpress/post/generic.rb', line 8
def parent_blog=(value)
@parent_blog = value
end
|
Instance Method Details
#assign_variables(args) ⇒ Object
20
21
22
|
# File 'lib/frenchpress/post/generic.rb', line 20
def assign_variables(args)
args.each(&method(:instance_variable_set)) end
|
#derive_variables ⇒ Object
24
25
26
27
28
|
# File 'lib/frenchpress/post/generic.rb', line 24
def derive_variables
@file_name = @date.strftime '%Y-%m-%d' + '-' + @title
@file_suffix = 'jpeg' if @file_suffix == 'jpg'
@file_suffix ||= 'html'
end
|
#render ⇒ Object
41
42
43
|
# File 'lib/frenchpress/post/generic.rb', line 41
def render
@content
end
|
#render_as_quote ⇒ Object
45
46
47
48
49
|
# File 'lib/frenchpress/post/generic.rb', line 45
def render_as_quote
"<a href=\"#{@parent_blog[:url]}\" class=\"quote-attr\">" \
"#{@parent_blog[:host]}</a>\n" \
"<blockquote>#{render}</blockquote>"
end
|
51
52
53
|
# File 'lib/frenchpress/post/generic.rb', line 51
def render_with_tags
(tags << render).join("\n")
end
|
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/frenchpress/post/generic.rb', line 30
def tags
[
'---',
"type: #{@type}",
"date: #{@date.strftime '%Y-%m-%d %H:%M:%S'}",
'layout: post',
"title: #{@title}",
'---'
]
end
|