Class: CombineHashtags::Post
- Inherits:
-
Object
- Object
- CombineHashtags::Post
- Defined in:
- lib/combine_hashtags/post.rb
Overview
Post class for profile content
Constant Summary collapse
[]
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#date ⇒ Object
Returns the value of attribute date.
-
#img_url ⇒ Object
Returns the value of attribute img_url.
-
#post_url ⇒ Object
Returns the value of attribute post_url.
-
#tags ⇒ Object
Returns the value of attribute tags.
Class Method Summary collapse
- .popular ⇒ Object
-
.tags ⇒ Object
TODO: verify if redundant & remove (added flatten! to instance var ^).
Instance Method Summary collapse
- #extract_tags ⇒ Object
-
#initialize(post_url, img_url, caption, timestamp) ⇒ Post
constructor
A new instance of Post.
Constructor Details
#initialize(post_url, img_url, caption, timestamp) ⇒ Post
Returns a new instance of Post.
12 13 14 15 16 17 18 19 |
# File 'lib/combine_hashtags/post.rb', line 12 def initialize(post_url, img_url, caption, ) @post_url = post_url @img_url = img_url @caption = caption @date = Date.parse() @tags = [] end |
Instance Attribute Details
#caption ⇒ Object
Returns the value of attribute caption.
8 9 10 |
# File 'lib/combine_hashtags/post.rb', line 8 def caption @caption end |
#date ⇒ Object
Returns the value of attribute date.
8 9 10 |
# File 'lib/combine_hashtags/post.rb', line 8 def date @date end |
#img_url ⇒ Object
Returns the value of attribute img_url.
8 9 10 |
# File 'lib/combine_hashtags/post.rb', line 8 def img_url @img_url end |
#post_url ⇒ Object
Returns the value of attribute post_url.
8 9 10 |
# File 'lib/combine_hashtags/post.rb', line 8 def post_url @post_url end |
#tags ⇒ Object
Returns the value of attribute tags.
8 9 10 |
# File 'lib/combine_hashtags/post.rb', line 8 def @tags end |
Class Method Details
.popular ⇒ Object
33 34 35 |
# File 'lib/combine_hashtags/post.rb', line 33 def self.popular .tally.select { |_, value| value > 3 } end |
.tags ⇒ Object
TODO: verify if redundant & remove (added flatten! to instance var ^)
29 30 31 |
# File 'lib/combine_hashtags/post.rb', line 29 def self. @@tags.flatten end |
Instance Method Details
#extract_tags ⇒ Object
21 22 23 24 25 26 |
# File 'lib/combine_hashtags/post.rb', line 21 def @tags << @caption.scan(/#\w*/) @tags.flatten! @@tags << @tags @tags = @tags.join(" ") end |