Class: QiitaMatome::Articles
- Inherits:
-
Object
- Object
- QiitaMatome::Articles
- Includes:
- Enumerable
- Defined in:
- lib/models/articles.rb
Overview
QiitaMatome::Articles
Instance Attribute Summary collapse
-
#articles ⇒ Object
Returns the value of attribute articles.
Class Method Summary collapse
Instance Method Summary collapse
- #+(other) ⇒ Object
- #<<(article) ⇒ Object
- #each ⇒ Object
- #filter_by_tag(tag) ⇒ Object
-
#initialize(articles = []) ⇒ Articles
constructor
A new instance of Articles.
- #size ⇒ Object
Constructor Details
#initialize(articles = []) ⇒ Articles
Returns a new instance of Articles.
15 16 17 |
# File 'lib/models/articles.rb', line 15 def initialize(articles = []) @articles = articles end |
Instance Attribute Details
#articles ⇒ Object
Returns the value of attribute articles.
7 8 9 |
# File 'lib/models/articles.rb', line 7 def articles @articles end |
Class Method Details
.exclude_uuid(target_articles, uuids) ⇒ Object
9 10 11 12 13 |
# File 'lib/models/articles.rb', line 9 def self.exclude_uuid(target_articles, uuids) uuids_list = Array(uuids) target_articles.delete_if { |e|uuids_list.include?(e.uuid) } target_articles end |
Instance Method Details
#+(other) ⇒ Object
23 24 25 26 |
# File 'lib/models/articles.rb', line 23 def +(other) @articles += other.articles self end |
#<<(article) ⇒ Object
19 20 21 |
# File 'lib/models/articles.rb', line 19 def <<(article) @articles << article end |
#each ⇒ Object
32 33 34 |
# File 'lib/models/articles.rb', line 32 def each @articles.each { |article|yield(article) } end |
#filter_by_tag(tag) ⇒ Object
36 37 38 |
# File 'lib/models/articles.rb', line 36 def filter_by_tag(tag) @articles.select { |e|e..map { |t|t['name'] }.include?(tag) } end |
#size ⇒ Object
28 29 30 |
# File 'lib/models/articles.rb', line 28 def size @articles.size end |