Class: Coffeemaker::Bot::Irc::Message
- Inherits:
-
Object
- Object
- Coffeemaker::Bot::Irc::Message
- Defined in:
- lib/coffeemaker/bot/irc/message.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
- #channel ⇒ Object
- #channel? ⇒ Boolean
- #command ⇒ Object
- #error ⇒ Object
- #error? ⇒ Boolean
- #host ⇒ Object
-
#initialize(msg = nil) ⇒ Message
constructor
A new instance of Message.
- #message ⇒ Object
- #nick ⇒ Object
- #numeric_reply ⇒ Object
- #numeric_reply? ⇒ Boolean
- #server ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(msg = nil) ⇒ Message
Returns a new instance of Message.
9 10 11 12 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 9 def initialize(msg = nil) @raw = msg parse if msg end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
7 8 9 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 7 def params @params end |
#prefix ⇒ Object
Returns the value of attribute prefix.
7 8 9 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 7 def prefix @prefix end |
#raw ⇒ Object
Returns the value of attribute raw.
7 8 9 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 7 def raw @raw end |
Instance Method Details
#channel ⇒ Object
56 57 58 59 60 61 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 56 def channel return @channel if @channel if regular_command? and params.first.start_with?("#") @channel = params.first end end |
#channel? ⇒ Boolean
52 53 54 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 52 def channel? !!channel end |
#command ⇒ Object
72 73 74 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 72 def command @command.downcase.to_sym end |
#error ⇒ Object
47 48 49 50 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 47 def error return @error if @error @error = @command.to_i if numeric_reply? && @command[/[45]\d\d/] end |
#error? ⇒ Boolean
43 44 45 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 43 def error? !!error end |
#host ⇒ Object
32 33 34 35 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 32 def host return unless @prefix @host ||= @prefix[/@(\S+)$/, 1] end |
#message ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 63 def return @message if @message if error? @message = error.to_s elsif regular_command? @message = params.last end end |
#nick ⇒ Object
22 23 24 25 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 22 def nick return unless @prefix @nick ||= @prefix[/^(\S+)!/, 1] end |
#numeric_reply ⇒ Object
18 19 20 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 18 def numeric_reply @numeric_reply ||= @command.match(/^\d\d\d$/) end |
#numeric_reply? ⇒ Boolean
14 15 16 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 14 def numeric_reply? !!numeric_reply end |
#server ⇒ Object
37 38 39 40 41 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 37 def server return unless @prefix return if @prefix.match(/[@!]/) @server ||= @prefix[/^(\S+)/, 1] end |
#user ⇒ Object
27 28 29 30 |
# File 'lib/coffeemaker/bot/irc/message.rb', line 27 def user return unless @prefix @user ||= @prefix[/^\S+!(\S+)@/, 1] end |