Class: JabberTee::Configuration
- Inherits:
-
Object
- Object
- JabberTee::Configuration
- Defined in:
- lib/jabber-tee/configuration.rb
Constant Summary collapse
- ATTRIBUTES =
[:username, :nick, :password, :anonymous, :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
- #in_room? ⇒ Boolean
-
#initialize(options = nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(options = nil) ⇒ Object
- #password ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Configuration
Returns a new instance of Configuration.
38 39 40 41 42 43 |
# File 'lib/jabber-tee/configuration.rb', line 38 def initialize(=nil) @username = @nick = @to = @room = @anonymous = @password = nil if !.nil? merge() end end |
Instance Attribute Details
#nick ⇒ Object (readonly)
Returns the value of attribute nick.
36 37 38 |
# File 'lib/jabber-tee/configuration.rb', line 36 def nick @nick end |
#room ⇒ Object (readonly)
Returns the value of attribute room.
36 37 38 |
# File 'lib/jabber-tee/configuration.rb', line 36 def room @room end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
36 37 38 |
# File 'lib/jabber-tee/configuration.rb', line 36 def to @to end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
36 37 38 |
# File 'lib/jabber-tee/configuration.rb', line 36 def username @username end |
Instance Method Details
#anonymous? ⇒ Boolean
58 59 60 |
# File 'lib/jabber-tee/configuration.rb', line 58 def anonymous? !@anonymous.nil? && username.nil? end |
#destination_missing? ⇒ Boolean
66 67 68 |
# File 'lib/jabber-tee/configuration.rb', line 66 def destination_missing? @room.nil? && @to.nil? end |
#in_room? ⇒ Boolean
62 63 64 |
# File 'lib/jabber-tee/configuration.rb', line 62 def in_room? !@room.nil? end |
#merge(options = nil) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/jabber-tee/configuration.rb', line 45 def merge(=nil) return self if .nil? ATTRIBUTES.each do |attr| value = [attr] || [attr.to_s] instance_variable_set("@#{attr}", value) if value end self end |
#password ⇒ Object
54 55 56 |
# File 'lib/jabber-tee/configuration.rb', line 54 def password @password ||= ask("#{username}: password: ") {|q| q.echo = false } end |