Class: Chat::DotCommand
- Inherits:
-
Object
- Object
- Chat::DotCommand
- Defined in:
- app/models/chat/dot_command.rb,
app/models/chat/dot_command/gif.rb,
app/models/chat/dot_command/shrug.rb,
app/models/chat/dot_command/validator.rb
Defined Under Namespace
Classes: Gif, Shrug, Validator
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(message, text) ⇒ DotCommand
constructor
A new instance of DotCommand.
- #perform ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(message, text) ⇒ DotCommand
Returns a new instance of DotCommand.
7 8 9 10 |
# File 'app/models/chat/dot_command.rb', line 7 def initialize(, text) @message = @text = text end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'app/models/chat/dot_command.rb', line 5 def @message end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'app/models/chat/dot_command.rb', line 5 def text @text end |
Instance Method Details
#command ⇒ Object
12 13 14 |
# File 'app/models/chat/dot_command.rb', line 12 def command @command ||= text[/^\.[a-zA-z]*/] end |
#perform ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/models/chat/dot_command.rb', line 16 def perform return false unless valid? ("Chat::DotCommand::" + command[1..-1].classify).constantize.new( , text[/[^\.[a-zA-z]*].*/]&.squish ).perform end |
#valid? ⇒ Boolean
24 25 26 |
# File 'app/models/chat/dot_command.rb', line 24 def valid? Chat::DotCommand::Validator.new(command).perform end |