Class: Eve::BaseRegistry

Inherits:
Registry show all
Defined in:
lib/registry/base_registry.rb

Constant Summary collapse

@@cmd_data =
{
  "export" => [],
  "import" => [],
  "sleep" => [],
  "ruby" => [],
}

Class Method Summary collapse

Methods inherited from Registry

handle, handle?

Class Method Details

.availableObject



12
13
14
# File 'lib/registry/base_registry.rb', line 12

def self.available
  @@cmd_data
end

.call_export(app, result, filename, display_messages) ⇒ Object


CALLER METHODS




20
21
22
23
24
25
26
# File 'lib/registry/base_registry.rb', line 20

def self.call_export(app,result,filename,display_messages)
  filename = "./eve.cmd" if filename == "" || filename.nil?
  result[:data] = filename
  IO.write(filename,app.cmds.join("\n"))
  app.message.print_exported_commands(filename) if display_messages
  result
end

.call_import(app, result, filename, display_messages) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/registry/base_registry.rb', line 28

def self.call_import(app,result,filename,display_messages)
  filename = "./eve.cmd" if filename == "" || filename.nil?
  result[:data] = filename
  result[:track_cmd] = false
  app.message.print_importing_commands(filename) if display_messages
  count = 0
  IO.readlines(filename).each do |raw|
    script = raw.strip
    next if script == "" || script[0] == "#"
    count += 1
    app.cmd(script,display_messages,true)
  end
  app.message.print_importing_complete(filename,count) if display_messages
  result
end

.call_ruby(app, result, call, display_messages) ⇒ Object



52
53
54
55
56
# File 'lib/registry/base_registry.rb', line 52

def self.call_ruby(app,result,call,display_messages)
  result[:data] = eval(call)
  app.message.print_ruby_call(call,result[:data]) if display_messages
  result
end

.call_sleep(app, result, duration, display_messages) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/registry/base_registry.rb', line 44

def self.call_sleep(app,result,duration,display_messages)
  in_secs = WatchMe::Timer.to_seconds(duration)
  result[:data] = in_secs
  app.message.print_sleep(in_secs) if display_messages
  Kernel.sleep(in_secs)
  result
end