class Bluebird::Strategies::Via::Strategy
Public Class Methods
run(tweet, config)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 7 def run(tweet, config) if run?(config.via.username) add_separator(tweet) tweet.add_partial(text(config.via), :via) end end
Private Class Methods
add_separator(tweet)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 20 def add_separator(tweet) if add_separator?(tweet) add_separator_partial?(tweet) ? add_separator_partial(tweet) : add_space_to_last_partial(tweet) end end
add_separator?(tweet)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 43 def add_separator?(tweet) tweet.partials.length > 0 end
add_separator_partial(tweet)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 47 def add_separator_partial(tweet) tweet.add_partial(' ', :text) end
add_separator_partial?(tweet)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 39 def add_separator_partial?(tweet) !tweet.partials.last.text? end
add_space_to_last_partial(tweet)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 51 def add_space_to_last_partial(tweet) last = tweet.partials.last unless last.content.end_with?(' ') last.content += ' ' end end
run?(username)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 16 def run?(username) username_exists?(username) ? true : raise('Bluebird: config.via.username is missing.') end
text(via_config)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 26 def text(via_config) "#{via_config.prefix} @#{via_config.username}" end
username_exists?(username)
click to toggle source
# File lib/bluebird/strategies/via/strategy.rb, line 30 def username_exists?(username) if username username.strip! !username.eql?('') else false end end