Class: Ambo::Deliveries::Twitter

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/ambo/deliveries/twitter.rb

Overview

This class is responsible for deliverying messages to Twitter using the Twitter::REST::Client class.

Defined Under Namespace

Classes: NullClient

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(twitter_config) ⇒ Twitter

Returns a new instance of Twitter.


10
11
12
13
14
15
16
# File 'lib/ambo/deliveries/twitter.rb', line 10

def initialize(twitter_config)
  if self.class.installed?
    initialize_twitter_client!(twitter_config)
  else
    initialize_null_client!
  end
end

Class Method Details

.installed?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/ambo/deliveries/twitter.rb', line 24

def self.installed?
  defined?(::Twitter) ? true : false
end

Instance Method Details

#send(msg_txt) ⇒ Object


18
19
20
21
22
# File 'lib/ambo/deliveries/twitter.rb', line 18

def send(msg_txt)
  info_log "Sending message to twitter; message=#{msg_txt.inspect}"

  @client.update msg_txt
end