Class: Termtter::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/termtter/hook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Hook

Returns a new instance of Hook.

Raises:

  • (ArgumentError)


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[:points].map {|i| i.to_sym } : []
  @exec_proc = args[:exec_proc] || lambda {}
end

Instance Attribute Details

#exec_procObject

Returns the value of attribute exec_proc.



5
6
7
# File 'lib/termtter/hook.rb', line 5

def exec_proc
  @exec_proc
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/termtter/hook.rb', line 5

def name
  @name
end

#pointsObject

Returns the value of attribute points.



5
6
7
# File 'lib/termtter/hook.rb', line 5

def points
  @points
end

Instance Method Details

#match?(point) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/termtter/hook.rb', line 14

def match?(point)
  points.include?(point.to_sym)
end