Class: RubyMarks::Watcher
- Inherits:
-
Object
- Object
- RubyMarks::Watcher
- Defined in:
- lib/ruby_marks/watcher.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#recognizer ⇒ Object
readonly
Returns the value of attribute recognizer.
Instance Method Summary collapse
-
#initialize(name, recognizer, &block) ⇒ Watcher
constructor
A new instance of Watcher.
- #run(*args) ⇒ Object
Constructor Details
#initialize(name, recognizer, &block) ⇒ Watcher
Returns a new instance of Watcher.
6 7 8 9 10 11 |
# File 'lib/ruby_marks/watcher.rb', line 6 def initialize(name, recognizer, &block) raise ArgumentError, "Invalid watcher name" unless RubyMarks::AVAILABLE_WATCHERS.include?(name) @name = name @recognizer = recognizer @action = block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/ruby_marks/watcher.rb', line 4 def name @name end |
#recognizer ⇒ Object (readonly)
Returns the value of attribute recognizer.
4 5 6 |
# File 'lib/ruby_marks/watcher.rb', line 4 def recognizer @recognizer end |
Instance Method Details
#run(*args) ⇒ Object
13 14 15 |
# File 'lib/ruby_marks/watcher.rb', line 13 def run(*args) @action.call(@recognizer, *args) if @action end |