Class: Bluebird::Tweet
- Inherits:
-
Object
- Object
- Bluebird::Tweet
- Includes:
- Twitter::Extractor
- Defined in:
- lib/bluebird/tweet.rb
Instance Attribute Summary collapse
-
#media ⇒ Object
readonly
Returns the value of attribute media.
-
#original_status ⇒ Object
readonly
Returns the value of attribute original_status.
-
#partials ⇒ Object
readonly
Returns the value of attribute partials.
Instance Method Summary collapse
- #add_partial(content, partial_type) ⇒ Object
- #cashtag_partials ⇒ Object
- #hashtag_partials ⇒ Object
-
#initialize(status, opts = {}) ⇒ Tweet
constructor
A new instance of Tweet.
- #length ⇒ Object
- #mention_partials ⇒ Object
- #status ⇒ Object
- #text_partials ⇒ Object
- #url_partials ⇒ Object
Constructor Details
#initialize(status, opts = {}) ⇒ Tweet
8 9 10 11 12 13 |
# File 'lib/bluebird/tweet.rb', line 8 def initialize(status, opts = {}) @original_status = status @partials = [] extract_partials(status) @media = opts[:media] if opts.has_key?(:media) end |
Instance Attribute Details
#media ⇒ Object (readonly)
Returns the value of attribute media.
6 7 8 |
# File 'lib/bluebird/tweet.rb', line 6 def media @media end |
#original_status ⇒ Object (readonly)
Returns the value of attribute original_status.
6 7 8 |
# File 'lib/bluebird/tweet.rb', line 6 def original_status @original_status end |
#partials ⇒ Object (readonly)
Returns the value of attribute partials.
6 7 8 |
# File 'lib/bluebird/tweet.rb', line 6 def partials @partials end |
Instance Method Details
#add_partial(content, partial_type) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bluebird/tweet.rb', line 43 def add_partial(content, partial_type) if eligible_content?(content) partial = Partial.new(content, partial_type) if (last = partials.last) last.next_partial = partial partial.prev_partial = last end partials << partial end end |
#cashtag_partials ⇒ Object
39 40 41 |
# File 'lib/bluebird/tweet.rb', line 39 def cashtag_partials partials.select { |partial| partial.cashtag? } end |
#hashtag_partials ⇒ Object
35 36 37 |
# File 'lib/bluebird/tweet.rb', line 35 def hashtag_partials partials.select { |partial| partial.hashtag? } end |
#length ⇒ Object
19 20 21 |
# File 'lib/bluebird/tweet.rb', line 19 def length total_partial_length + media_length end |
#mention_partials ⇒ Object
31 32 33 |
# File 'lib/bluebird/tweet.rb', line 31 def mention_partials partials.select { |partial| partial.mention? } end |
#status ⇒ Object
15 16 17 |
# File 'lib/bluebird/tweet.rb', line 15 def status partials.map { |partial| partial.content }.join end |
#text_partials ⇒ Object
23 24 25 |
# File 'lib/bluebird/tweet.rb', line 23 def text_partials partials.select { |partial| partial.text? } end |
#url_partials ⇒ Object
27 28 29 |
# File 'lib/bluebird/tweet.rb', line 27 def url_partials partials.select { |partial| partial.url? } end |