Class: Strigil::Comment
- Inherits:
-
Object
- Object
- Strigil::Comment
- Defined in:
- lib/strigil/comment.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#subreddit ⇒ Object
readonly
Returns the value of attribute subreddit.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize(params = {}) ⇒ Comment
constructor
A new instance of Comment.
- #to_json ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Comment
Returns a new instance of Comment.
6 7 8 9 10 11 12 |
# File 'lib/strigil/comment.rb', line 6 def initialize(params={}) @author = params[:author] @subreddit = params[:subreddit] @permalink = params[:permalink] @timestamp = Time.parse(params[:timestamp]) @text = params[:text] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
4 5 6 |
# File 'lib/strigil/comment.rb', line 4 def @author end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
4 5 6 |
# File 'lib/strigil/comment.rb', line 4 def permalink @permalink end |
#subreddit ⇒ Object (readonly)
Returns the value of attribute subreddit.
4 5 6 |
# File 'lib/strigil/comment.rb', line 4 def subreddit @subreddit end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'lib/strigil/comment.rb', line 4 def text @text end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
4 5 6 |
# File 'lib/strigil/comment.rb', line 4 def @timestamp end |
Instance Method Details
#display ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/strigil/comment.rb', line 24 def display %{ posted by #{} on /r/#{subreddit} #{} | #{permalink} ------------------------------------- #{text} } end |
#to_json ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/strigil/comment.rb', line 14 def to_json { author: , subreddit: subreddit, permalink: permalink, timestamp: , text: text }.to_json end |