Class: BlogGenerator::PostList
- Inherits:
-
Object
- Object
- BlogGenerator::PostList
- Extended by:
- Forwardable
- Defined in:
- lib/blog-generator/post_list.rb
Instance Attribute Summary collapse
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(site, posts = Array.new) ⇒ PostList
constructor
A new instance of PostList.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(site, posts = Array.new) ⇒ PostList
Returns a new instance of PostList.
9 10 11 |
# File 'lib/blog-generator/post_list.rb', line 9 def initialize(site, posts = Array.new) @site, @posts = site, posts end |
Instance Attribute Details
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
8 9 10 |
# File 'lib/blog-generator/post_list.rb', line 8 def posts @posts end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
8 9 10 |
# File 'lib/blog-generator/post_list.rb', line 8 def site @site end |
Instance Method Details
#as_json ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/blog-generator/post_list.rb', line 15 def as_json self.posts.map do |post| post.as_json.tap do || .delete(:body) end end end |
#to_json(*args) ⇒ Object
23 24 25 |
# File 'lib/blog-generator/post_list.rb', line 23 def to_json(*args) self.as_json.to_json(*args) end |