Class: RHosts::Console
- Inherits:
-
Object
- Object
- RHosts::Console
- Includes:
- Alias, ConsoleMethods, Rulable
- Defined in:
- lib/rhosts/commands/console.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Console
constructor
A new instance of Console.
- #start ⇒ Object
Methods included from Alias
#alias_host, #alias_hosts, #alias_ip, #alias_ips, included
Methods included from Rulable
Methods included from ConsoleMethods
#actives, #display, #inactives, #map, #unmap
Constructor Details
Class Method Details
.start ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rhosts/commands/console.rb', line 17 def start @console = new load_default_rules load_run_command unless File.writable?(RHosts.config.hosts_file_path) STDERR.puts "Hosts file is not writable. Please check permission" exit 1 end @console.start end |
Instance Method Details
#start ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rhosts/commands/console.rb', line 50 def start while command = Readline.readline('rhosts> ', true) # call matched rule with captures rules.each{ |rule, action| action.call($~.captures) if rule.match command.chomp } end end |