Class: Monster::Post
- Inherits:
-
Object
- Object
- Monster::Post
- Defined in:
- lib/monster/post.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](metadata_key) ⇒ Object
- #[]=(metadata_key, value) ⇒ Object
- #author=(author) ⇒ Object
- #blog_root=(path) ⇒ Object
- #category=(category) ⇒ Object
- #create_draft ⇒ Object
- #date ⇒ Object
- #date_generator=(generator) ⇒ Object
-
#initialize(title) ⇒ Post
constructor
A new instance of Post.
- #meta=(metadata_hash) ⇒ Object
- #slug ⇒ Object
Constructor Details
#initialize(title) ⇒ Post
Returns a new instance of Post.
20 21 22 |
# File 'lib/monster/post.rb', line 20 def initialize(title) @title = title end |
Class Method Details
.default_draft(title, generator) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/monster/post.rb', line 5 def self.default_draft(title, generator) post = Post.new(title) post.date_generator = generator post. = Author.new("Ricardo Valeriano") post. = { :category => "Desenvolvimento", :tags => [], :type => "post", :published => false, :excerpt => title } post.create_draft post end |
Instance Method Details
#[](metadata_key) ⇒ Object
63 64 65 66 |
# File 'lib/monster/post.rb', line 63 def []() = .to_s unless .class == String [.downcase] end |
#[]=(metadata_key, value) ⇒ Object
58 59 60 61 |
# File 'lib/monster/post.rb', line 58 def []=(, value) = .to_s unless .class == String [.downcase] = value end |
#author=(author) ⇒ Object
24 25 26 |
# File 'lib/monster/post.rb', line 24 def () @author = end |
#blog_root=(path) ⇒ Object
40 41 42 |
# File 'lib/monster/post.rb', line 40 def blog_root=(path) @root = path end |
#category=(category) ⇒ Object
44 45 46 |
# File 'lib/monster/post.rb', line 44 def category=(category) @category = category end |
#create_draft ⇒ Object
48 49 50 51 52 |
# File 'lib/monster/post.rb', line 48 def create_draft File.open(File.join(posts_dir, file_name), "w") do |file| file << end end |
#date ⇒ Object
36 37 38 |
# File 'lib/monster/post.rb', line 36 def date @date_generator.call end |
#date_generator=(generator) ⇒ Object
32 33 34 |
# File 'lib/monster/post.rb', line 32 def date_generator=(generator) @date_generator = generator end |
#meta=(metadata_hash) ⇒ Object
54 55 56 |
# File 'lib/monster/post.rb', line 54 def () .each { |key, value| self[key] = value } end |
#slug ⇒ Object
28 29 30 |
# File 'lib/monster/post.rb', line 28 def slug @slug ||= @title.slugify end |