Class: ProcSettingManager

Inherits:
Object
  • Object
show all
Defined in:
lib/statsailr/block_to_r/proc_setting_support/proc_setting_manager.rb

Instance Method Summary collapse

Constructor Details

#initializeProcSettingManager

Returns a new instance of ProcSettingManager.



4
5
6
# File 'lib/statsailr/block_to_r/proc_setting_support/proc_setting_manager.rb', line 4

def initialize
  @proc_settings = {} # "command(downcase)" => { "path" => Pathname(abslute path) , "loaded" => boolean }
end

Instance Method Details

#add_proc_settings_from_dir(dir) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/statsailr/block_to_r/proc_setting_support/proc_setting_manager.rb', line 8

def add_proc_settings_from_dir( dir )
  raise "add_proc_settings_from_directory() requires String" unless dir.is_a? String
  dir_pathname = Pathname.new(dir)
  if ! dir_pathname.absolute?
    raise "dir should be specified in absolute path."
  end

  dir_pathname.opendir{|d|
    d.each(){|f|
      if((dir_pathname + f).file?)
        if( f =~ /proc_([a-zA-Z0-9]+)\.rb/ )
          command_name = $1
          proc_setting_path = dir_pathname + f
          @proc_settings[command_name.downcase] = { "path" => proc_setting_path, "loaded" => false }
        end
      end
    }
  }
end

#is_loaded?(command) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'lib/statsailr/block_to_r/proc_setting_support/proc_setting_manager.rb', line 28

def is_loaded?( command )
  command = command.downcase
  if @proc_settings.has_key? command 
    return @proc_settings[command]["loaded"]
  else
    return false
  end
end

#load_setting(command) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/statsailr/block_to_r/proc_setting_support/proc_setting_manager.rb', line 37

def load_setting( command )
  command = command.downcase
  if @proc_settings.has_key? command 
    load( @proc_settings[command]["path"].to_s )
    @proc_settings[command]["loaded"] = true
  else
    raise "specified #{command} proc command cannot be found. Loaded proc settings: #{@proc_settings.keys} "
  end
end