Class: AutoResp::AutoResponder
- Inherits:
-
Object
- Object
- AutoResp::AutoResponder
- Defined in:
- lib/autoresponse.rb
Constant Summary collapse
- ARHOME =
"#{ENV["HOME"]}/.auto_response"- RULES =
"#{ARHOME}/rules"
Instance Method Summary collapse
- #add_rule(*args, &block) ⇒ Object
- #clear_rules ⇒ Object
-
#initialize(config = {}) ⇒ AutoResponder
constructor
A new instance of AutoResponder.
- #rules ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #stop_and_exit ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ AutoResponder
Returns a new instance of AutoResponder.
28 29 30 31 32 33 34 35 36 |
# File 'lib/autoresponse.rb', line 28 def initialize(config={}) @config = config @rule_manager = RuleManager.new init_autoresponse_home init_proxy_server load_rules monitor_rules_change start_viewer end |
Instance Method Details
#add_rule(*args, &block) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/autoresponse.rb', line 86 def add_rule(*args, &block) case args.first when Hash rules.merge! args.first when String rules[args[0]] = args[1] when Regexp if block_given? rules[args[0]] = block else rules[args[0]] = args[1] end end end |
#clear_rules ⇒ Object
105 106 107 |
# File 'lib/autoresponse.rb', line 105 def clear_rules rules.clear end |
#rules ⇒ Object
101 102 103 |
# File 'lib/autoresponse.rb', line 101 def rules @rule_manager.rules end |
#start ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/autoresponse.rb', line 67 def start @thread = Thread.new { sleep 0.1 @server.start } @thread.join end |
#stop ⇒ Object
80 81 82 83 84 |
# File 'lib/autoresponse.rb', line 80 def stop puts "\nshuting down" @server.shutdown @thread.kill end |
#stop_and_exit ⇒ Object
75 76 77 78 |
# File 'lib/autoresponse.rb', line 75 def stop_and_exit stop exit end |