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.
19 20 21 22 23 24 25 26 |
# File 'lib/autoresponse.rb', line 19 def initialize(config={}) @config = config @rule_manager = RuleManager.new init_autoresponse_home init_proxy_server load_rules monitor_rules_change end |
Instance Method Details
#add_rule(*args, &block) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/autoresponse.rb', line 64 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
83 84 85 |
# File 'lib/autoresponse.rb', line 83 def clear_rules rules.clear end |
#rules ⇒ Object
79 80 81 |
# File 'lib/autoresponse.rb', line 79 def rules @rule_manager.rules end |
#start ⇒ Object
48 49 50 51 |
# File 'lib/autoresponse.rb', line 48 def start @thread = Thread.new { @server.start } @thread.join end |
#stop ⇒ Object
58 59 60 61 62 |
# File 'lib/autoresponse.rb', line 58 def stop puts "\nshuting down" @server.shutdown @thread.kill end |
#stop_and_exit ⇒ Object
53 54 55 56 |
# File 'lib/autoresponse.rb', line 53 def stop_and_exit stop exit end |