Class: IIRC::Event
- Inherits:
-
Object
- Object
- IIRC::Event
- Defined in:
- lib/iirc/event.rb
Direct Known Subclasses
Constant Summary collapse
- CTCP_REGEX =
/^\x01(\w+)(?: ([^\x01]+))?\x01?$/
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#verb ⇒ Object
Returns the value of attribute verb.
Instance Method Summary collapse
-
#ctcp ⇒ Array<Symbol, String?>?
Parses CTCP data in message, returning nil or an Array like [:action, "does the Macarena"], [:version], [:version, "SomeClient v0.1"].
- #ctcp? ⇒ Boolean
- #ctcp_message ⇒ Object
- #ctcp_verb ⇒ Object
-
#initialize(sender: nil, verb: nil, args: nil, tags: nil) ⇒ Event
constructor
A new instance of Event.
- #message ⇒ Object
- #nick ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(sender: nil, verb: nil, args: nil, tags: nil) ⇒ Event
Returns a new instance of Event.
5 6 7 8 9 10 |
# File 'lib/iirc/event.rb', line 5 def initialize(sender: nil, verb: nil, args: nil, tags: nil) self.sender = sender self.verb = verb self.args = args self. = end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/iirc/event.rb', line 3 def args @args end |
#sender ⇒ Object
Returns the value of attribute sender.
3 4 5 |
# File 'lib/iirc/event.rb', line 3 def sender @sender end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/iirc/event.rb', line 3 def @tags end |
#verb ⇒ Object
Returns the value of attribute verb.
3 4 5 |
# File 'lib/iirc/event.rb', line 3 def verb @verb end |
Instance Method Details
#ctcp ⇒ Array<Symbol, String?>?
Parses CTCP data in message, returning nil or an Array like [:action, "does the Macarena"], [:version], [:version, "SomeClient v0.1"]
62 63 64 |
# File 'lib/iirc/event.rb', line 62 def ctcp [ctcp_verb, ].compact if ctcp? end |
#ctcp_message ⇒ Object
42 43 44 |
# File 'lib/iirc/event.rb', line 42 def $2 if =~ CTCP_REGEX end |
#ctcp_verb ⇒ Object
38 39 40 |
# File 'lib/iirc/event.rb', line 38 def ctcp_verb $1.downcase.to_sym if =~ CTCP_REGEX end |
#message ⇒ Object
28 29 30 |
# File 'lib/iirc/event.rb', line 28 def args.last end |
#nick ⇒ Object
20 21 22 |
# File 'lib/iirc/event.rb', line 20 def nick sender&.nick end |
#target ⇒ Object
24 25 26 |
# File 'lib/iirc/event.rb', line 24 def target args.first end |