Class: Miyano::Post
- Inherits:
-
Object
- Object
- Miyano::Post
- Defined in:
- lib/miyano/post.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#cre_date ⇒ Object
readonly
Returns the value of attribute cre_date.
-
#mod_date ⇒ Object
readonly
Returns the value of attribute mod_date.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #content_for_homepage ⇒ Object
- #content_no_assets ⇒ Object
- #date(format = "%b %-d, %Y") ⇒ Object
-
#initialize(name, cre_date, mod_date, title = "", content = "", text = "", tags = []) ⇒ Post
constructor
A new instance of Post.
- #summary ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(name, cre_date, mod_date, title = "", content = "", text = "", tags = []) ⇒ Post
Returns a new instance of Post.
8 9 10 11 12 13 14 |
# File 'lib/miyano/post.rb', line 8 def initialize(name, cre_date, mod_date, title="", content="", text="", =[]) @name, @title = name, title @cre_date, @mod_date = cre_date, mod_date @content, @text, @tags = content, text, @url = "/#{@name}/" end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def content @content end |
#cre_date ⇒ Object (readonly)
Returns the value of attribute cre_date.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def cre_date @cre_date end |
#mod_date ⇒ Object (readonly)
Returns the value of attribute mod_date.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def mod_date @mod_date end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def name @name end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def text @text end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/miyano/post.rb', line 3 def url @url end |
Instance Method Details
#content_for_homepage ⇒ Object
33 34 35 36 |
# File 'lib/miyano/post.rb', line 33 def content_for_homepage res=@content.gsub /\=\"assets\//, %(="#{@url}assets/) res[(@title.length+9)..-1] end |
#content_no_assets ⇒ Object
28 29 30 31 |
# File 'lib/miyano/post.rb', line 28 def content_no_assets res = @content.gsub /<p.*?\=\"assets\/.*?p>/, "" res[(@title.length+9)..-1] end |
#date(format = "%b %-d, %Y") ⇒ Object
16 17 18 |
# File 'lib/miyano/post.rb', line 16 def date(format="%b %-d, %Y") @mod_date.strftime format end |
#summary ⇒ Object
24 25 26 |
# File 'lib/miyano/post.rb', line 24 def summary @text[(@title.length+2)..-1].delete "#*" end |
#tags ⇒ Object
20 21 22 |
# File 'lib/miyano/post.rb', line 20 def @tags end |