Class: Miyano::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/miyano/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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="", tags=[])
  @name, @title = name, title
  @cre_date, @mod_date = cre_date, mod_date
  @content, @text, @tags = content, text, tags
  @url = "/#{@name}/"
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/miyano/post.rb', line 3

def content
  @content
end

#cre_dateObject (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_dateObject (readonly)

Returns the value of attribute mod_date.



3
4
5
# File 'lib/miyano/post.rb', line 3

def mod_date
  @mod_date
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/miyano/post.rb', line 3

def name
  @name
end

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'lib/miyano/post.rb', line 3

def text
  @text
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/miyano/post.rb', line 3

def title
  @title
end

#urlObject (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_homepageObject



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_assetsObject



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

#summaryObject



24
25
26
# File 'lib/miyano/post.rb', line 24

def summary
  @text[(@title.length+2)..-1].delete "#*"
end

#tagsObject



20
21
22
# File 'lib/miyano/post.rb', line 20

def tags
  @tags
end