Module: T::Requestable
- Included in:
- CLI::Delete, CLI::Follow, CLI::List, CLI::List::Add, CLI::List::Remove, CLI::Search, CLI::Set, CLI::Unfollow
- Defined in:
- lib/t/requestable.rb
Constant Summary collapse
- DEFAULT_HOST =
'api.twitter.com'
- DEFAULT_PROTOCOL =
'https'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/t/requestable.rb', line 8 def self.included(base) private def base_url "#{protocol}://#{host}" end def client return @client if @client @rcfile.path = ['profile'] if ['profile'] @client = Twitter::Client.new( :endpoint => base_url, :consumer_key => @rcfile.default_consumer_key, :consumer_secret => @rcfile.default_consumer_secret, :oauth_token => @rcfile.default_token, :oauth_token_secret => @rcfile.default_secret ) end def host ['host'] || DEFAULT_HOST end def protocol ['no_ssl'] ? 'http' : DEFAULT_PROTOCOL end end |
Instance Method Details
#base_url ⇒ Object
12 13 14 |
# File 'lib/t/requestable.rb', line 12 def base_url "#{protocol}://#{host}" end |
#client ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/t/requestable.rb', line 16 def client return @client if @client @rcfile.path = ['profile'] if ['profile'] @client = Twitter::Client.new( :endpoint => base_url, :consumer_key => @rcfile.default_consumer_key, :consumer_secret => @rcfile.default_consumer_secret, :oauth_token => @rcfile.default_token, :oauth_token_secret => @rcfile.default_secret ) end |
#host ⇒ Object
28 29 30 |
# File 'lib/t/requestable.rb', line 28 def host ['host'] || DEFAULT_HOST end |
#protocol ⇒ Object
32 33 34 |
# File 'lib/t/requestable.rb', line 32 def protocol ['no_ssl'] ? 'http' : DEFAULT_PROTOCOL end |