Class: Tweetwine::Tweet
- Inherits:
-
Object
- Object
- Tweetwine::Tweet
- Defined in:
- lib/tweetwine/tweet.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#from_user ⇒ Object
readonly
Returns the value of attribute from_user.
-
#rt_user ⇒ Object
readonly
Returns the value of attribute rt_user.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#to_user ⇒ Object
readonly
Returns the value of attribute to_user.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(record, paths) ⇒ Tweet
constructor
A new instance of Tweet.
- #reply? ⇒ Boolean
- #retweet? ⇒ Boolean
- #status? ⇒ Boolean
- #timestamped? ⇒ Boolean
Constructor Details
#initialize(record, paths) ⇒ Tweet
Returns a new instance of Tweet.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tweetwine/tweet.rb', line 7 def initialize(record, paths) if field_present? record, paths[:retweet] @rt_user = parse_string_field record, paths[:from_user] fields = Support.find_hash_path record, paths[:retweet] else @rt_user = nil fields = record end @to_user = parse_string_field fields, paths[:to_user] @from_user = parse_string_field fields, paths[:from_user] raise ArgumentError, 'from user record field is required' unless @from_user @created_at = parse_time_field fields, paths[:created_at] @status = parse_string_field fields, paths[:status] end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/tweetwine/tweet.rb', line 5 def created_at @created_at end |
#from_user ⇒ Object (readonly)
Returns the value of attribute from_user.
5 6 7 |
# File 'lib/tweetwine/tweet.rb', line 5 def from_user @from_user end |
#rt_user ⇒ Object (readonly)
Returns the value of attribute rt_user.
5 6 7 |
# File 'lib/tweetwine/tweet.rb', line 5 def rt_user @rt_user end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/tweetwine/tweet.rb', line 5 def status @status end |
#to_user ⇒ Object (readonly)
Returns the value of attribute to_user.
5 6 7 |
# File 'lib/tweetwine/tweet.rb', line 5 def to_user @to_user end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/tweetwine/tweet.rb', line 38 def ==(other) other.is_a?(self.class) && self.rt_user == other.rt_user && self.to_user == other.to_user && self.from_user == other.from_user && self.created_at == other.created_at && self.status == other.status end |
#reply? ⇒ Boolean
34 35 36 |
# File 'lib/tweetwine/tweet.rb', line 34 def reply? !@to_user.nil? end |
#retweet? ⇒ Boolean
26 27 28 |
# File 'lib/tweetwine/tweet.rb', line 26 def retweet? !@rt_user.nil? end |
#status? ⇒ Boolean
30 31 32 |
# File 'lib/tweetwine/tweet.rb', line 30 def status? !@status.nil? end |
#timestamped? ⇒ Boolean
22 23 24 |
# File 'lib/tweetwine/tweet.rb', line 22 def !@created_at.nil? end |