Class: Ircp::Prefix
- Inherits:
-
Object
- Object
- Ircp::Prefix
- Defined in:
- lib/ircp/prefix.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#nick ⇒ Object
Returns the value of attribute nick.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#servername ⇒ Object
Returns the value of attribute servername.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(options = {}) {|_self| ... } ⇒ Prefix
constructor
A new instance of Prefix.
- #inspect ⇒ Object
- #to_irc ⇒ Object (also: #to_s)
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Prefix
Returns a new instance of Prefix.
5 6 7 8 9 10 11 12 |
# File 'lib/ircp/prefix.rb', line 5 def initialize( = {}) @raw = [:raw] @servername = [:servername] @nick = [:nick] @user = [:user] @host = [:host] yield self if block_given? end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/ircp/prefix.rb', line 3 def host @host end |
#nick ⇒ Object
Returns the value of attribute nick.
3 4 5 |
# File 'lib/ircp/prefix.rb', line 3 def nick @nick end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/ircp/prefix.rb', line 3 def raw @raw end |
#servername ⇒ Object
Returns the value of attribute servername.
3 4 5 |
# File 'lib/ircp/prefix.rb', line 3 def servername @servername end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/ircp/prefix.rb', line 3 def user @user end |
Instance Method Details
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/ircp/prefix.rb', line 14 def empty? to_s.empty? end |
#inspect ⇒ Object
18 19 20 21 22 |
# File 'lib/ircp/prefix.rb', line 18 def inspect variables = instance_variables.map { |name| "#{name}=#{instance_variable_get(name).inspect}" } variables.unshift "#{self.class}" "<#{variables.join ' '}>" end |
#to_irc ⇒ Object Also known as: to_s
24 25 26 27 28 29 30 31 32 |
# File 'lib/ircp/prefix.rb', line 24 def to_irc if @servername "#{servername}" else [['', @nick], ['!', @user], ['@', @host]].map do |mark, value| "#{mark}#{value}" unless value.to_s.empty? end.compact.join('') end end |