Class: FilterBestPosts
- Inherits:
-
Object
- Object
- FilterBestPosts
- Defined in:
- lib/filter_best_posts.rb
Instance Attribute Summary collapse
-
#filtered_posts ⇒ Object
Returns the value of attribute filtered_posts.
-
#posts ⇒ Object
Returns the value of attribute posts.
Instance Method Summary collapse
- #filter ⇒ Object
-
#initialize(topic, filtered_posts, limit, options = {}) ⇒ FilterBestPosts
constructor
A new instance of FilterBestPosts.
Constructor Details
#initialize(topic, filtered_posts, limit, options = {}) ⇒ FilterBestPosts
Returns a new instance of FilterBestPosts.
6 7 8 9 10 11 12 |
# File 'lib/filter_best_posts.rb', line 6 def initialize(topic, filtered_posts, limit, = {}) @filtered_posts = filtered_posts @topic = topic @limit = limit .each { |key, value| self.instance_variable_set("@#{key}".to_sym, value) } filter end |
Instance Attribute Details
#filtered_posts ⇒ Object
Returns the value of attribute filtered_posts.
4 5 6 |
# File 'lib/filter_best_posts.rb', line 4 def filtered_posts @filtered_posts end |
#posts ⇒ Object
Returns the value of attribute posts.
4 5 6 |
# File 'lib/filter_best_posts.rb', line 4 def posts @posts end |
Instance Method Details
#filter ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/filter_best_posts.rb', line 14 def filter @posts = if @min_replies && @topic.posts_count < @min_replies + 1 Post.none else filter_posts_liked_by_moderators setup_posts filter_posts_based_on_trust_level filter_posts_based_on_score sort_posts end end |