Class: Bluebird::Partial

Inherits:
Object
  • Object
show all
Defined in:
lib/bluebird/partial.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, partial_type) ⇒ Partial

Returns a new instance of Partial.



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

def initialize(content, partial_type)
  @content      = content
  @partial_type = partial_type
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/bluebird/partial.rb', line 4

def content
  @content
end

#next_partialObject

Returns the value of attribute next_partial.



4
5
6
# File 'lib/bluebird/partial.rb', line 4

def next_partial
  @next_partial
end

#prev_partialObject

Returns the value of attribute prev_partial.



4
5
6
# File 'lib/bluebird/partial.rb', line 4

def prev_partial
  @prev_partial
end

Instance Method Details

#cashtag?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/bluebird/partial.rb', line 47

def cashtag?
  @partial_type.eql?(:cashtag)
end

#entity?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/bluebird/partial.rb', line 51

def entity?
  !text?
end

#first?Boolean

Returns:

  • (Boolean)


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

def first?
  !prev_partial
end

#hashtag?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/bluebird/partial.rb', line 43

def hashtag?
  @partial_type.eql?(:hashtag)
end

#https?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/bluebird/partial.rb', line 65

def https?
  url? && content.start_with?('https://')
end

#last?Boolean

Returns:

  • (Boolean)


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

def last?
  !next_partial
end

#lengthObject



11
12
13
14
15
16
17
# File 'lib/bluebird/partial.rb', line 11

def length
  if url?
    https? ? Config.short_url_length_https : Config.short_url_length
  else
    content.char_length
  end
end

#list?Boolean

Returns:

  • (Boolean)


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

def list?
  @partial_type.eql?(:list)
end

#mention?Boolean

Returns:

  • (Boolean)


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

def mention?
  @partial_type.eql?(:mention)
end

#reply_preventer?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/bluebird/partial.rb', line 61

def reply_preventer?
  first? && next_partial && next_partial.mention?
end

#separator?Boolean

Returns:

  • (Boolean)


55
56
57
58
59
# File 'lib/bluebird/partial.rb', line 55

def separator?
  # separates two entities
  # ex: @iekutlu and @mekanio => " and " is a separater
  prev_partial && prev_partial.entity? && next_partial && next_partial.entity?
end

#text?Boolean

Returns:

  • (Boolean)


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

def text?
  @partial_type.eql?(:text)
end

#url?Boolean

Returns:

  • (Boolean)


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

def url?
  @partial_type.eql?(:url)
end