Class: Post
- Inherits:
-
Object
- Object
- Post
- Defined in:
- lib/simpleblog/post.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#post_content ⇒ Object
readonly
Returns the value of attribute post_content.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, post_content) ⇒ Post
constructor
A new instance of Post.
- #tags ⇒ Object
Constructor Details
#initialize(id, post_content) ⇒ Post
Returns a new instance of Post.
10 11 12 13 |
# File 'lib/simpleblog/post.rb', line 10 def initialize(id, post_content) @id = id @post_content = post_content end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
21 22 23 24 25 26 27 28 29 |
# File 'lib/simpleblog/post.rb', line 21 def method_missing(method, *args, &block) if post_content[method.to_s] self.class.define_method(method.to_s) do post_content[method.to_s] end send method, *args, &block end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/simpleblog/post.rb', line 8 def id @id end |
#post_content ⇒ Object (readonly)
Returns the value of attribute post_content.
8 9 10 |
# File 'lib/simpleblog/post.rb', line 8 def post_content @post_content end |
Class Method Details
Instance Method Details
#tags ⇒ Object
15 16 17 |
# File 'lib/simpleblog/post.rb', line 15 def post_content["tags"].gsub(/\s+/, "").split(",") end |