Class: Tweet
- Inherits:
-
Object
- Object
- Tweet
- Includes:
- Contracts::Core
- Defined in:
- lib/tweet.rb,
lib/tweet/tag_too_long.rb
Overview
Extending lib/tweet
Defined Under Namespace
Classes: TagTooLong
Constant Summary collapse
- C =
Shortcut for Contracts
Contracts
Instance Attribute Summary collapse
-
#link ⇒ Object
Returns the value of attribute link.
-
#post ⇒ Object
Returns the value of attribute post.
Instance Method Summary collapse
-
#add(tag) ⇒ Object
Add tag to @post.
-
#initialize(link) ⇒ Tweet
constructor
A new instance of Tweet.
-
#to_s ⇒ Object
Output the post.
Constructor Details
#initialize(link) ⇒ Tweet
Returns a new instance of Tweet.
15 16 17 18 |
# File 'lib/tweet.rb', line 15 def initialize(link) @link = link @post = "| #{@link}" end |
Instance Attribute Details
#link ⇒ Object
Returns the value of attribute link.
8 9 10 |
# File 'lib/tweet.rb', line 8 def link @link end |
#post ⇒ Object
Returns the value of attribute post.
9 10 11 |
# File 'lib/tweet.rb', line 9 def post @post end |
Instance Method Details
#add(tag) ⇒ Object
Add tag to @post
22 23 24 25 26 27 28 29 |
# File 'lib/tweet.rb', line 22 def add(tag) temp_post = "| #{tag} #{@post}" if temp_post.length <= 140 @post = "| #{tag} #{@post}" else fail Tweet::TagTooLong end end |
#to_s ⇒ Object
Output the post
33 34 35 |
# File 'lib/tweet.rb', line 33 def to_s @post.to_s end |