Class: Yaic::Source
- Inherits:
-
Object
- Object
- Yaic::Source
- Defined in:
- lib/yaic/source.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#nick ⇒ Object
readonly
Returns the value of attribute nick.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(nick: nil, user: nil, host: nil, raw: nil) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(nick: nil, user: nil, host: nil, raw: nil) ⇒ Source
Returns a new instance of Source.
7 8 9 10 11 12 |
# File 'lib/yaic/source.rb', line 7 def initialize(nick: nil, user: nil, host: nil, raw: nil) @nick = nick @user = user @host = host @raw = raw end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/yaic/source.rb', line 5 def host @host end |
#nick ⇒ Object (readonly)
Returns the value of attribute nick.
5 6 7 |
# File 'lib/yaic/source.rb', line 5 def nick @nick end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/yaic/source.rb', line 5 def raw @raw end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/yaic/source.rb', line 5 def user @user end |
Class Method Details
.parse(str) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/yaic/source.rb', line 14 def self.parse(str) return nil if str.nil? || str.empty? nick = nil user = nil host = nil if str.include?("!") nick, rest = str.split("!", 2) if rest.include?("@") user, host = rest.split("@", 2) else user = rest end elsif str.include?("@") nick, host = str.split("@", 2) elsif str.include?(".") host = str else nick = str end new(nick: nick, user: user, host: host, raw: str) end |