Class: Bluebird::Tweet

Inherits:
Object
  • Object
show all
Includes:
Twitter::Extractor
Defined in:
lib/bluebird/tweet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mediaObject (readonly)

Returns the value of attribute media.



6
7
8
# File 'lib/bluebird/tweet.rb', line 6

def media
  @media
end

#original_statusObject (readonly)

Returns the value of attribute original_status.



6
7
8
# File 'lib/bluebird/tweet.rb', line 6

def original_status
  @original_status
end

#partialsObject (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_partialsObject



39
40
41
# File 'lib/bluebird/tweet.rb', line 39

def cashtag_partials
  partials.select { |partial| partial.cashtag? }
end

#hashtag_partialsObject



35
36
37
# File 'lib/bluebird/tweet.rb', line 35

def hashtag_partials
  partials.select { |partial| partial.hashtag? }
end

#lengthObject



19
20
21
# File 'lib/bluebird/tweet.rb', line 19

def length
  total_partial_length + media_length
end

#mention_partialsObject



31
32
33
# File 'lib/bluebird/tweet.rb', line 31

def mention_partials
  partials.select { |partial| partial.mention? }
end

#statusObject



15
16
17
# File 'lib/bluebird/tweet.rb', line 15

def status
  partials.map { |partial| partial.content }.join
end

#text_partialsObject



23
24
25
# File 'lib/bluebird/tweet.rb', line 23

def text_partials
  partials.select { |partial| partial.text? }
end

#url_partialsObject



27
28
29
# File 'lib/bluebird/tweet.rb', line 27

def url_partials
  partials.select { |partial| partial.url? }
end