Class: Vk::Post::Wall
- Inherits:
-
Object
- Object
- Vk::Post::Wall
- Defined in:
- lib/vk/post/wall.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#posts ⇒ Object
Returns the value of attribute posts.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(uid, count, posts) ⇒ Wall
constructor
A new instance of Wall.
- #method_missing(method, *args) ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(uid, count, posts) ⇒ Wall
Returns a new instance of Wall.
10 11 12 |
# File 'lib/vk/post/wall.rb', line 10 def initialize(uid, count, posts) self.uid, self.count, self.posts = uid, count, posts end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/vk/post/wall.rb', line 34 def method_missing(method, *args) if posts.respond_to?(method) posts.send(method, *args) else super end end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
8 9 10 |
# File 'lib/vk/post/wall.rb', line 8 def count @count end |
#posts ⇒ Object
Returns the value of attribute posts.
8 9 10 |
# File 'lib/vk/post/wall.rb', line 8 def posts @posts end |
#uid ⇒ Object
Returns the value of attribute uid.
8 9 10 |
# File 'lib/vk/post/wall.rb', line 8 def uid @uid end |
Instance Method Details
#[](index) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/vk/post/wall.rb', line 18 def [](index) raise "Post #{index} is not exist" if index > count + 1 load_posts_to(index) if index >= loaded_posts post = posts[index] Vk::Post.find(Vk::Post.id_for(post), data: post) if post end |
#each(&block) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/vk/post/wall.rb', line 27 def each(&block) load_all_posts 0.upto(count) do |index| block.call(self[index]) end end |
#first ⇒ Object
25 |
# File 'lib/vk/post/wall.rb', line 25 def first; self[0]; end |