Class: LongTweet::Splitter
- Inherits:
-
Object
- Object
- LongTweet::Splitter
show all
- Defined in:
- lib/long_tweet/splitter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(text) ⇒ Splitter
Returns a new instance of Splitter.
4
5
6
7
|
# File 'lib/long_tweet/splitter.rb', line 4
def initialize text
@text = text
@splitter = set_splitter
end
|
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
3
4
5
|
# File 'lib/long_tweet/splitter.rb', line 3
def text
@text
end
|
Instance Method Details
#set_splitter ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/long_tweet/splitter.rb', line 9
def set_splitter
if text.split.any? {|e| e.length > 140 }
NaiveSplitter.new text
else
IdealSplitter.new text
end
end
|
#split ⇒ Object
23
24
25
|
# File 'lib/long_tweet/splitter.rb', line 23
def split
@splitter.split
end
|
17
18
19
20
21
|
# File 'lib/long_tweet/splitter.rb', line 17
def
= text.length/140
+= 1 if text.length.modulo(140) > 0
end
|