Class: Rog::Post

Inherits:
Rote::Page show all
Includes:
Comparable
Defined in:
lib/rog/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rote::Page

#title

Constructor Details

#initialize(path, blog_path = 'blog', pages_path = "#{blog_path}/pages", posts_path = "#{pages_path}/posts") ⇒ Post

Returns a new instance of Post.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rog/post.rb', line 28

def initialize(path, blog_path='blog', pages_path="#{blog_path}/pages", posts_path="#{pages_path}/posts")
  path =~ /(\d\d\d\d)(\d\d)(\d\d)[-].*\.thtml$/
  @year, @month, @day = $1, $2, $3
  @page_path = path

  super(path, posts_path, "#{blog_path}/layouts") do |page|
    relpath = path.sub(/\..*$/,'.html') # genera il nome della pagina formattata
    @page_url = relpath
    page.instance_eval("@page_name = '#{relpath}'") # e istanzia una variabile di pagina
    page.instance_eval("@post_date = '#{@year}-#{@month}-#{@day}'")
  end

  extend Rote::Format::HTML
  @page_filters.insert(0, Rote::Filters::RedCloth.new)
  layout('post_mini')
end

Instance Attribute Details

#dayObject (readonly)

Returns the value of attribute day.



26
27
28
# File 'lib/rog/post.rb', line 26

def day
  @day
end

#monthObject (readonly)

Returns the value of attribute month.



26
27
28
# File 'lib/rog/post.rb', line 26

def month
  @month
end

#yearObject (readonly)

Returns the value of attribute year.



26
27
28
# File 'lib/rog/post.rb', line 26

def year
  @year
end

Instance Method Details

#<=>(other) ⇒ Object



61
62
63
# File 'lib/rog/post.rb', line 61

def <=>(other)
  [@year, @month, @day] <=> [other.year, other.month, other.day] 
end

#dateObject



57
58
59
# File 'lib/rog/post.rb', line 57

def date
  "#{@year}-#{@month}-#{@day}"
end

#pathObject



49
50
51
# File 'lib/rog/post.rb', line 49

def path
  @page_path
end

#tagsObject



45
46
47
# File 'lib/rog/post.rb', line 45

def tags
  @page_tags
end

#urlObject



53
54
55
# File 'lib/rog/post.rb', line 53

def url
  @page_url
end