Class: Ellen::Action
- Inherits:
-
Object
- Object
- Ellen::Action
- Defined in:
- lib/ellen/action.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(action) ⇒ Object
- #all? ⇒ Boolean
- #call(handler, message) ⇒ Object
- #description ⇒ Object
- #hidden? ⇒ Boolean
-
#initialize(pattern, options = {}) ⇒ Action
constructor
A new instance of Action.
- #name ⇒ Object
Constructor Details
#initialize(pattern, options = {}) ⇒ Action
Returns a new instance of Action.
9 10 11 12 |
# File 'lib/ellen/action.rb', line 9 def initialize(pattern, = {}) @pattern = pattern @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/ellen/action.rb', line 7 def @options end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
7 8 9 |
# File 'lib/ellen/action.rb', line 7 def pattern @pattern end |
Class Method Details
.prefix_pattern(robot_name) ⇒ Object
3 4 5 |
# File 'lib/ellen/action.rb', line 3 def self.prefix_pattern(robot_name) /\A@?#{Regexp.escape(robot_name)}:?\s*/ end |
Instance Method Details
#<=>(action) ⇒ Object
34 35 36 |
# File 'lib/ellen/action.rb', line 34 def <=>(action) pattern.to_s <=> action.pattern.to_s end |
#all? ⇒ Boolean
18 19 20 |
# File 'lib/ellen/action.rb', line 18 def all? !![:all] end |
#call(handler, message) ⇒ Object
14 15 16 |
# File 'lib/ellen/action.rb', line 14 def call(handler, ) handler.send(name, ) if .match pattern_with(handler.robot.name) end |
#description ⇒ Object
22 23 24 |
# File 'lib/ellen/action.rb', line 22 def description [:description] || "(no description)" end |
#hidden? ⇒ Boolean
26 27 28 |
# File 'lib/ellen/action.rb', line 26 def hidden? !![:hidden] end |
#name ⇒ Object
30 31 32 |
# File 'lib/ellen/action.rb', line 30 def name [:name] end |