Class: Rog::Blog
- Inherits:
-
Object
- Object
- Rog::Blog
- Defined in:
- lib/rog/blog.rb
Instance Attribute Summary collapse
-
#blog_subtitle ⇒ Object
readonly
Returns the value of attribute blog_subtitle.
-
#blog_title ⇒ Object
readonly
Returns the value of attribute blog_title.
-
#buttons ⇒ Object
readonly
Returns the value of attribute buttons.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
-
#publish_url ⇒ Object
readonly
Returns the value of attribute publish_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #each_month(&proc) ⇒ Object
- #each_post(&proc) ⇒ Object
- #get_last_posts ⇒ Object
-
#initialize(blog_path = 'blog', pages_path = "#{blog_path}/pages", archives_path = "#{pages_path}/archives", posts_path = "#{pages_path}/posts") ⇒ Blog
constructor
A new instance of Blog.
- #posts ⇒ Object
- #posts? ⇒ Boolean
- #tags ⇒ Object
Constructor Details
#initialize(blog_path = 'blog', pages_path = "#{blog_path}/pages", archives_path = "#{pages_path}/archives", posts_path = "#{pages_path}/posts") ⇒ Blog
Returns a new instance of Blog.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rog/blog.rb', line 53 def initialize(blog_path='blog', pages_path="#{blog_path}/pages", archives_path = "#{pages_path}/archives", posts_path="#{pages_path}/posts") @blog_path = blog_path @pages_path = pages_path @archives_path = archives_path @posts_path = posts_path @tags_hash = Hash.new load_config scan_for_posts end |
Instance Attribute Details
#blog_subtitle ⇒ Object (readonly)
Returns the value of attribute blog_subtitle.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def blog_subtitle @blog_subtitle end |
#blog_title ⇒ Object (readonly)
Returns the value of attribute blog_title.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def blog_title @blog_title end |
#buttons ⇒ Object (readonly)
Returns the value of attribute buttons.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def @buttons end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def links @links end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def pages @pages end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def projects @projects end |
#publish_url ⇒ Object (readonly)
Returns the value of attribute publish_url.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def publish_url @publish_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
50 51 52 |
# File 'lib/rog/blog.rb', line 50 def url @url end |
Instance Method Details
#each_month(&proc) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/rog/blog.rb', line 85 def each_month(&proc) prev_year = @blog_posts[0].year prev_month = @blog_posts[0].month month_posts = Array.new @blog_posts << nil @blog_posts.each do |post| if (not post.nil?) and (post.year == prev_year and post.month == prev_month) then month_posts.push post else yield month_posts break if post.nil? prev_year = post.year prev_month = post.month month_posts = [ post ] end end @blog_posts.pop #yield [ @blog_posts.last ] if not month_posts.include? @blog_posts.last end |
#each_post(&proc) ⇒ Object
79 80 81 82 83 |
# File 'lib/rog/blog.rb', line 79 def each_post(&proc) @blog_posts.each do |bpost| yield bpost end end |
#get_last_posts ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rog/blog.rb', line 110 def get_last_posts last_posts = Array.new (0...7).each do |i| if not @blog_posts[i].nil? last_posts.push @blog_posts[i] else break end end last_posts end |
#posts ⇒ Object
71 72 73 |
# File 'lib/rog/blog.rb', line 71 def posts @blog_posts end |
#posts? ⇒ Boolean
75 76 77 |
# File 'lib/rog/blog.rb', line 75 def posts? @blog_posts.length >= 1 end |
#tags ⇒ Object
67 68 69 |
# File 'lib/rog/blog.rb', line 67 def @tags_hash end |