Class: Net::IRC::CTCP
- Inherits:
-
Object
- Object
- Net::IRC::CTCP
- Defined in:
- lib/net/irc.rb
Direct Known Subclasses
CTCPAction, CTCPClientinfo, CTCPDcc, CTCPErrmsg, CTCPFinger, CTCPPing, CTCPPlay, CTCPTime, CTCPVersion
Constant Summary collapse
- CTCP_REGEX =
/\001(.*?)\001/
Instance Attribute Summary collapse
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(keyword, *parameters) ⇒ CTCP
constructor
A new instance of CTCP.
- #to_s ⇒ Object
Constructor Details
#initialize(keyword, *parameters) ⇒ CTCP
Returns a new instance of CTCP.
33 34 35 36 37 |
# File 'lib/net/irc.rb', line 33 def initialize(keyword, *parameters) @source = nil @keyword = keyword @parameters = parameters end |
Instance Attribute Details
#keyword ⇒ Object
Returns the value of attribute keyword.
29 30 31 |
# File 'lib/net/irc.rb', line 29 def keyword @keyword end |
#parameters ⇒ Object
Returns the value of attribute parameters.
29 30 31 |
# File 'lib/net/irc.rb', line 29 def parameters @parameters end |
#source ⇒ Object
Returns the value of attribute source.
29 30 31 |
# File 'lib/net/irc.rb', line 29 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
29 30 31 |
# File 'lib/net/irc.rb', line 29 def target @target end |
Class Method Details
.parse(text) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/net/irc.rb', line 46 def parse(text) [ text.gsub(CTCP_REGEX, ''), text.scan(CTCP_REGEX).flatten.collect do || parameters = .split(' ') case keyword = parameters.shift when 'VERSION' CTCPVersion.new(*parameters) when 'PING' CTCPPing.new(*parameters) when 'CLIENTINFO' CTCPClientinfo.new(*parameters) when 'ACTION' CTCPAction.new(*parameters) when 'FINGER' CTCPFinger.new(*parameters) when 'TIME' CTCPTime.new(*parameters) when 'DCC' CTCPDcc.new(*parameters) when 'ERRMSG' CTCPErrmsg.new(*parameters) when 'PLAY' CTCPPlay.new(*parameters) else CTCP.new(keyword, *parameters) end end ] end |
Instance Method Details
#to_s ⇒ Object
39 40 41 42 43 |
# File 'lib/net/irc.rb', line 39 def to_s str = "\001#{keyword}" str << parameters.collect { |p| " #{p}"}.join str << "\001" end |