Class: JabberTee::Client
- Inherits:
-
Object
- Object
- JabberTee::Client
- Defined in:
- lib/jabber-tee/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #pump! ⇒ Object
- #say(message) ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jabber-tee/client.rb', line 11 def initialize(config) @config = config @client = Jabber::Client.new(Jabber::JID.new("#{config.username}/#{config.nick}")) client.connect client.auth(config.password) if config.in_room? @muc = Jabber::MUC::SimpleMUCClient.new(client) @muc.join(Jabber::JID.new("#{config.room}/#{config.nick}")) end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/jabber-tee/client.rb', line 9 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/jabber-tee/client.rb', line 9 def config @config end |
Instance Method Details
#pump! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jabber-tee/client.rb', line 23 def pump! if $stdin.tty? $STDERR.puts "Unable to pipe jabber-tee from a TTY" exit(1) else $stdin.each do |line| line.chomp! say(line) puts line end end end |
#say(message) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/jabber-tee/client.rb', line 36 def say() if config.in_room? @muc.say() else msg = Jabber::Message.new(config.to, ) msg.type = :chat client.send(msg) end end |