Class: AutoResp::AutoResponder
- Inherits:
-
Object
- Object
- AutoResp::AutoResponder
- Defined in:
- lib/auto_response.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.
24 25 26 27 28 29 30 31 |
# File 'lib/auto_response.rb', line 24 def initialize(config={}) @config = config @rule_manager = RuleManager.new @logger = Logger.new( $stderr, Logger::WARN ) init_autoresponse_home load_rules monitor_rules_change end |
Instance Method Details
#add_rule(*args, &block) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/auto_response.rb', line 81 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
100 101 102 |
# File 'lib/auto_response.rb', line 100 def clear_rules rules.clear end |
#rules ⇒ Object
96 97 98 |
# File 'lib/auto_response.rb', line 96 def rules @rule_manager.rules end |
#start ⇒ Object
64 65 66 67 68 |
# File 'lib/auto_response.rb', line 64 def start log_rules start_proxy start_viewer end |
#stop ⇒ Object
75 76 77 78 79 |
# File 'lib/auto_response.rb', line 75 def stop @server.shutdown @viewer_thread.kill @proxy_thread.kill end |
#stop_and_exit ⇒ Object
70 71 72 73 |
# File 'lib/auto_response.rb', line 70 def stop_and_exit stop exit end |