Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rum/dsl.rb

Instance Method Summary collapse

Instance Method Details

#do(*args, &block) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rum/dsl.rb', line 61

def do(*options, &action)
  repeated = true
  options.reject! do |option|
    case option
    when :no_repeat
      repeated = false
    when String
      action = lambda { Keyboard.type option }
    end
  end
  if (condition = options.first) and condition.respond_to? :to_matcher
    matcher = condition.to_matcher
    condition = lambda { matcher.active? }
  end
  location = FileLocation.from_stack_frame(caller.first)
  Rum.hotkey_set.add_hotkey(self, action, condition, repeated, location)
end

#old_doObject

Prepare a special version of #do that is only active when the user calls #do for the first time. After running Rum.setup it calls and restores the default version of #do.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rum/dsl.rb', line 95

def do(*options, &action)
  repeated = true
  options.reject! do |option|
    case option
    when :no_repeat
      repeated = false
    when String
      action = lambda { Keyboard.type option }
    end
  end
  if (condition = options.first) and condition.respond_to? :to_matcher
    matcher = condition.to_matcher
    condition = lambda { matcher.active? }
  end
  location = FileLocation.from_stack_frame(caller.first)
  Rum.hotkey_set.add_hotkey(self, action, condition, repeated, location)
end

#translate(condition = nil, to) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/rum/dsl.rb', line 83

def translate condition=nil, to
  if condition and condition.respond_to? :to_matcher
    matcher = condition.to_matcher
    condition = lambda { matcher.active? }
  end
  Rum.hotkey_set.add_translation(self, to, condition,
                                 FileLocation.from_stack_frame(caller.first))
end

#unregisterObject



79
80
81
# File 'lib/rum/dsl.rb', line 79

def unregister
  Rum.hotkey_set.remove_hotkey(self)
end