Class: IRC::Message
- Inherits:
-
Object
- Object
- IRC::Message
- Defined in:
- lib/rhuidean/client.rb
Overview
A simple data-holding class.
Constant Summary collapse
- ORIGIN_RE =
constants
/^(.+)\!(.+)\@(.+)$/
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
instance attributes.
-
#ctcp ⇒ Object
readonly
instance attributes.
-
#origin ⇒ Object
readonly
instance attributes.
-
#origin_host ⇒ Object
readonly
Returns the value of attribute origin_host.
-
#origin_nick ⇒ Object
readonly
Returns the value of attribute origin_nick.
-
#origin_user ⇒ Object
readonly
Returns the value of attribute origin_user.
-
#params ⇒ Object
readonly
instance attributes.
-
#raw ⇒ Object
readonly
instance attributes.
-
#target ⇒ Object
readonly
instance attributes.
Instance Method Summary collapse
-
#action? ⇒ Boolean
- Was the message formatted as a CTCP action? — returns
-
trueorfalse.
-
#ctcp? ⇒ Boolean
- Was the message formatted as a CTCP message? — returns
-
trueorfalse.
-
#dcc? ⇒ Boolean
- Was the message formatted as a DCC notice? — returns
-
trueorfalse.
-
#initialize(client, raw, origin, target, params) ⇒ Message
constructor
Creates a new Message.
-
#to_channel? ⇒ Boolean
- Was the message sent to a channel? — returns
-
trueorfalse.
Constructor Details
#initialize(client, raw, origin, target, params) ⇒ Message
Creates a new Message. We use these to represent the old style of (char *origin, char *target, char *parv[]) in C.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/rhuidean/client.rb', line 453 def initialize(client, raw, origin, target, params) # The IRC::Client that processed this message @client = client # If this is a CTCP, the type of CTCP @ctcp = nil # The originator of the message. Sometimes server, sometimes n!u@h @origin = origin # A space-tokenized array of anything after a colon @params = params # The full string from the IRC server @raw = raw # Usually the intended recipient; usually a user or channel @target = target # Is the origin a user? Let's make this a little more simple... if m = ORIGIN_RE.match(@origin) @origin_nick, @origin_user, @origin_host = m[1..3] end # Reformat it a bit if it's a CTCP. if @params and not @params.empty? and @params[0][0] == "\1" @params[-1].chop! @ctcp = @params.shift[1 .. -1].downcase.to_sym end end |
Instance Attribute Details
#client ⇒ Object (readonly)
instance attributes
446 447 448 |
# File 'lib/rhuidean/client.rb', line 446 def client @client end |
#ctcp ⇒ Object (readonly)
instance attributes
446 447 448 |
# File 'lib/rhuidean/client.rb', line 446 def ctcp @ctcp end |
#origin ⇒ Object (readonly)
instance attributes
446 447 448 |
# File 'lib/rhuidean/client.rb', line 446 def origin @origin end |
#origin_host ⇒ Object (readonly)
Returns the value of attribute origin_host.
447 448 449 |
# File 'lib/rhuidean/client.rb', line 447 def origin_host @origin_host end |
#origin_nick ⇒ Object (readonly)
Returns the value of attribute origin_nick.
447 448 449 |
# File 'lib/rhuidean/client.rb', line 447 def origin_nick @origin_nick end |
#origin_user ⇒ Object (readonly)
Returns the value of attribute origin_user.
447 448 449 |
# File 'lib/rhuidean/client.rb', line 447 def origin_user @origin_user end |
#params ⇒ Object (readonly)
instance attributes
446 447 448 |
# File 'lib/rhuidean/client.rb', line 446 def params @params end |
#raw ⇒ Object (readonly)
instance attributes
446 447 448 |
# File 'lib/rhuidean/client.rb', line 446 def raw @raw end |
#target ⇒ Object (readonly)
instance attributes
446 447 448 |
# File 'lib/rhuidean/client.rb', line 446 def target @target end |
Instance Method Details
#action? ⇒ Boolean
Was the message formatted as a CTCP action?
- returns
-
trueorfalse
511 512 513 |
# File 'lib/rhuidean/client.rb', line 511 def action? @ctcp == :action end |
#ctcp? ⇒ Boolean
Was the message formatted as a CTCP message?
- returns
-
trueorfalse
502 503 504 |
# File 'lib/rhuidean/client.rb', line 502 def ctcp? @ctcp end |
#dcc? ⇒ Boolean
Was the message formatted as a DCC notice?
- returns
-
trueorfalse
520 521 522 |
# File 'lib/rhuidean/client.rb', line 520 def dcc? @ctcp == :dcc end |
#to_channel? ⇒ Boolean
Was the message sent to a channel?
- returns
-
trueorfalse
493 494 495 |
# File 'lib/rhuidean/client.rb', line 493 def to_channel? %w(# & !).include?(@target[0]) end |