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.



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

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

Instance Attribute Details

#contentObject

Returns the value of attribute content.



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

def content
  @content
end

#next_partialObject

Returns the value of attribute next_partial.



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

def next_partial
  @next_partial
end

#partial_typeObject (readonly)

Returns the value of attribute partial_type.



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

def partial_type
  @partial_type
end

#prev_partialObject

Returns the value of attribute prev_partial.



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

def prev_partial
  @prev_partial
end

Instance Method Details

#cashtag?Boolean

Returns:

  • (Boolean)


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

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

#entity?Boolean

Returns:

  • (Boolean)


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

def entity?
  !text?
end

#first?Boolean

Returns:

  • (Boolean)


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

def first?
  !prev_partial
end

#hashtag?Boolean

Returns:

  • (Boolean)


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

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

#https?Boolean

Returns:

  • (Boolean)


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

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

#last?Boolean

Returns:

  • (Boolean)


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

def last?
  !next_partial
end

#lengthObject



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

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

#list?Boolean

Returns:

  • (Boolean)


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

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

#mention?Boolean

Returns:

  • (Boolean)


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

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

#reply_preventer?Boolean

Returns:

  • (Boolean)


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

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

#separator?Boolean

Returns:

  • (Boolean)


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

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)


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

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

#url?Boolean

Returns:

  • (Boolean)


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

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