Class: JabberTee::Configuration
- Inherits:
-
Object
- Object
- JabberTee::Configuration
- Defined in:
- lib/jabber-tee/configuration.rb
Constant Summary collapse
- ATTRIBUTES =
['username', 'nick', 'password', 'anonymous', 'sasl', 'digest', 'room', 'to']
Instance Attribute Summary collapse
-
#nick ⇒ Object
readonly
Returns the value of attribute nick.
-
#room ⇒ Object
readonly
Returns the value of attribute room.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #anonymous? ⇒ Boolean
- #destination_missing? ⇒ Boolean
- #digest? ⇒ Boolean
- #in_room? ⇒ Boolean
-
#initialize(options = nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(options) ⇒ Object
- #password ⇒ Object
- #sasl? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Configuration
Returns a new instance of Configuration.
43 44 45 46 47 |
# File 'lib/jabber-tee/configuration.rb', line 43 def initialize(=nil) if !.nil? merge() end end |
Instance Attribute Details
#nick ⇒ Object (readonly)
Returns the value of attribute nick.
41 42 43 |
# File 'lib/jabber-tee/configuration.rb', line 41 def nick @nick end |
#room ⇒ Object (readonly)
Returns the value of attribute room.
41 42 43 |
# File 'lib/jabber-tee/configuration.rb', line 41 def room @room end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
41 42 43 |
# File 'lib/jabber-tee/configuration.rb', line 41 def to @to end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
41 42 43 |
# File 'lib/jabber-tee/configuration.rb', line 41 def username @username end |
Instance Method Details
#anonymous? ⇒ Boolean
66 67 68 |
# File 'lib/jabber-tee/configuration.rb', line 66 def anonymous? !@anonymous.nil? && username.nil? end |
#destination_missing? ⇒ Boolean
82 83 84 |
# File 'lib/jabber-tee/configuration.rb', line 82 def destination_missing? @room.nil? && @to.nil? end |
#digest? ⇒ Boolean
74 75 76 |
# File 'lib/jabber-tee/configuration.rb', line 74 def digest? !@digest.nil? end |
#in_room? ⇒ Boolean
78 79 80 |
# File 'lib/jabber-tee/configuration.rb', line 78 def in_room? !@room.nil? end |
#merge(options) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/jabber-tee/configuration.rb', line 49 def merge() ATTRIBUTES.each do |attr| if .has_key?(attr.to_sym) || .has_key?(attr) value = [attr.to_sym] || [attr] instance_variable_set("@#{attr}", value) end end self end |
#password ⇒ Object
59 60 61 62 63 64 |
# File 'lib/jabber-tee/configuration.rb', line 59 def password if @password.nil? @password = ask("#{username}: password: ") {|q| q.echo = false } end @password end |
#sasl? ⇒ Boolean
70 71 72 |
# File 'lib/jabber-tee/configuration.rb', line 70 def sasl? !@sasl.nil? end |
#to_s ⇒ Object
86 87 88 |
# File 'lib/jabber-tee/configuration.rb', line 86 def to_s "<JabberTee::Configuration{:username => '#{username}', :room => '#{room}', :to => '#{to}', :anonymous => #{anonymous?}, :sasl => #{sasl?}}>" end |