Top Level Namespace

Defined Under Namespace

Modules: Finexclub, Generator Classes: FakeUpdater

Constant Summary collapse

STRATEGIES =
%w(trends finexclub octopus prognosis)
FINEXCLUB_TIMEFRAMES =
%w(h1 h4 d1)
TRENDSONFOREX_SYMBOLS =
Finexclub::Chart::SYMBOLS
FINEXCLUB_SYMBOLS =
%w(eurusd gbpusd eurgbp audusd usdjpy usdcad)

Instance Method Summary collapse

Instance Method Details

#autoload_files_in_dir(path, namespace) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/finexclub.rb', line 15

def autoload_files_in_dir(path, namespace)
  # Define the module
  eval("module #{namespace}; end")
  # Autoload modules/classes in that module
  Dir.glob("#{path}/*.rb").each do |file|
    file = File.expand_path(file)
    sub_const_name = camelize( File.basename(file, '.rb') )
    eval("#{namespace}.autoload('#{sub_const_name}', '#{file}')")
  end
  # Recurse on subdirectories
  Dir.glob("#{path}/*/").each do |dir|
    sub_namespace = camelize( File.basename(dir) )
    autoload_files_in_dir(dir, "#{namespace}::#{sub_namespace}")
  end
end

#camelize(path) ⇒ Object

The convention is that dirs are modules so declare them here and autoload any modules/classes inside them All paths here are absolute



6
7
8
9
10
11
12
13
14
# File 'lib/finexclub.rb', line 6

def camelize(path)
  # e.g. 'test/this_one' => Test::ThisOne
  "#{path}".
    chomp('/').
    gsub('/','::').
    gsub(/([^a-z])(\w)/){ "#{$1}#{$2.upcase}" }.
    gsub('_','').
    sub(/^(\w)/){ $1.upcase }
end