Class: RubyMarks::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_marks/watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, recognizer, &block) ⇒ Watcher

Returns a new instance of Watcher.

Raises:

  • (ArgumentError)


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

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/ruby_marks/watcher.rb', line 4

def name
  @name
end

#recognizerObject (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