Class: Termtter::Hook
- Inherits:
-
Object
- Object
- Termtter::Hook
- Defined in:
- lib/termtter/hook.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#exec_proc ⇒ Object
Returns the value of attribute exec_proc.
-
#name ⇒ Object
Returns the value of attribute name.
-
#points ⇒ Object
Returns the value of attribute points.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(args) ⇒ Hook
constructor
A new instance of Hook.
- #match?(point) ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Hook
Returns a new instance of Hook.
7 8 9 10 11 12 |
# File 'lib/termtter/hook.rb', line 7 def initialize(args) raise ArgumentError, ":name is not given." unless args.has_key?(:name) @name = args[:name].to_sym @points = args[:points] || [args[:point]].compact @exec_proc = args[:exec_proc] || args[:exec] || lambda {} end |
Instance Attribute Details
#exec_proc ⇒ Object
Returns the value of attribute exec_proc.
5 6 7 |
# File 'lib/termtter/hook.rb', line 5 def exec_proc @exec_proc end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/termtter/hook.rb', line 5 def name @name end |
#points ⇒ Object
Returns the value of attribute points.
5 6 7 |
# File 'lib/termtter/hook.rb', line 5 def points @points end |
Instance Method Details
#call(*args) ⇒ Object
27 28 29 |
# File 'lib/termtter/hook.rb', line 27 def call(*args) self.exec_proc.call(*args) end |