Class: Zwite::Blog::Post
Instance Attribute Summary collapse
-
#archive ⇒ Object
Returns the value of attribute archive.
-
#blog ⇒ Object
Properties.
-
#content ⇒ Object
Returns the value of attribute content.
-
#date ⇒ Object
Returns the value of attribute date.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#topics ⇒ Object
Returns the value of attribute topics.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Actions.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(blog, path) ⇒ Post
constructor
Initialization.
- #to_liquid ⇒ Object
Constructor Details
#initialize(blog, path) ⇒ Post
Initialization
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/zwite/plugins/blog.rb', line 158 def initialize(blog, path) self.blog = blog self.path = path Zwite::Utils.parse_date_and_slug(self.path.basename.to_s) do |date, slug| self.date = date self.slug = slug end self.archive = Archive.new(blog, date.year, date.month) self.url = "#{self.blog.app.url}blog/#{self.date.strftime("%Y/%m/%d")}/#{self.slug}/" Zwite::Utils.((self.path + "post.md").read) do |, markdown| self. = self.content = markdown end self.name = self.["name"] self.topics = [] self.["topics"].each do |topic| self.topics << Topic.new(blog, topic) end self.topics.sort! end |
Instance Attribute Details
#archive ⇒ Object
Returns the value of attribute archive.
120 121 122 |
# File 'lib/zwite/plugins/blog.rb', line 120 def archive @archive end |
#blog ⇒ Object
Properties
116 117 118 |
# File 'lib/zwite/plugins/blog.rb', line 116 def blog @blog end |
#content ⇒ Object
Returns the value of attribute content.
125 126 127 |
# File 'lib/zwite/plugins/blog.rb', line 125 def content @content end |
#date ⇒ Object
Returns the value of attribute date.
119 120 121 |
# File 'lib/zwite/plugins/blog.rb', line 119 def date @date end |
#metadata ⇒ Object
Returns the value of attribute metadata.
124 125 126 |
# File 'lib/zwite/plugins/blog.rb', line 124 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
127 128 129 |
# File 'lib/zwite/plugins/blog.rb', line 127 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
117 118 119 |
# File 'lib/zwite/plugins/blog.rb', line 117 def path @path end |
#slug ⇒ Object
Returns the value of attribute slug.
121 122 123 |
# File 'lib/zwite/plugins/blog.rb', line 121 def slug @slug end |
#topics ⇒ Object
Returns the value of attribute topics.
128 129 130 |
# File 'lib/zwite/plugins/blog.rb', line 128 def topics @topics end |
#url ⇒ Object
Returns the value of attribute url.
122 123 124 |
# File 'lib/zwite/plugins/blog.rb', line 122 def url @url end |
Instance Method Details
#<=>(other) ⇒ Object
Actions
189 190 191 192 193 194 |
# File 'lib/zwite/plugins/blog.rb', line 189 def <=>(other) if other.class == self.class return other.date <=> self.date end return nil end |
#eql?(other) ⇒ Boolean
130 131 132 133 134 135 |
# File 'lib/zwite/plugins/blog.rb', line 130 def eql?(other) if other.class == self.class return other.path == self.path end return false end |
#hash ⇒ Object
137 138 139 |
# File 'lib/zwite/plugins/blog.rb', line 137 def hash return self.to_liquid.hash end |
#to_liquid ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/zwite/plugins/blog.rb', line 141 def to_liquid return { "date" => self.date, "archive" => self.archive, "slug" => self.slug, "url" => self.url, "metadata" => self., "content" => self.content, "name" => self.name, "topics" => self.topics, } end |