Module: AMS::Lib

Defined in:
../ams_Lib.rb,
main.rb

Constant Summary

NAME =
'AMS Library'.freeze
VERSION =
'2.1.0'.freeze
RELEASE_DATE =
'December 03, 2014'.freeze
PATH =

Get folder location.

File.dirname(__FILE__).freeze
BASE =

Get name of the main file.

File.basename(__FILE__).freeze

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Class Attribute Details

+ (Object) extension (readonly)

Returns the value of attribute extension



48
49
50
# File '../ams_Lib.rb', line 48

def extension
  @extension
end

Class Method Details

+ (Object) clean_up

Since:

  • 2.1.0



173
174
175
176
177
178
179
180
181
182
# File 'main.rb', line 173

def clean_up
  count = 0
  Dir.glob( File.join(PATH, '*.{rb, rbs}') ).each { |fpath|
    base_name = File.basename(fpath)
    next if base_name == BASE || REGISTERED_FILES.include?(base_name)
    File.delete(fpath)
    count += 1
  }
  count
end

+ (Boolean) load(file_name)

Note:

The file will be reloaded if it was already loaded.

Load specific file within the library's path.

Parameters:

  • file_name (String)

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



165
166
167
168
# File 'main.rb', line 165

def load(file_name)
  fpath = File.join(PATH, file_name)
  load fpath
end

+ (Fixnum) load_all

Note:

All already loaded files will be reloaded.

Load all library.

Returns:

  • (Fixnum)

    number of files loaded.

Since:

  • 2.0.0



139
140
141
142
143
144
145
146
147
148
# File 'main.rb', line 139

def load_all
  count = 0
  Dir.glob( File.join(PATH, '*.{rb, rbs}') ).each { |fpath|
    base_name = File.basename(fpath)
    next if base_name == BASE || !REGISTERED_FILES.include?(base_name)
    Kernel.load fpath
    count += 1
  }
  count
end

+ (Boolean) require(file_name)

Note:

The file will not be loaded if it was already loaded.

Require specific file within the library's path.

Parameters:

  • file_name (String)

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



155
156
157
158
# File 'main.rb', line 155

def require(file_name)
  fpath = File.join(PATH, file_name)
  Kernel.require fpath
end

+ (Fixnum) require_all

Note:

All already loaded files will be ignored.

Require all library.

Returns:

  • (Fixnum)

    number of files required.

Since:

  • 2.0.0



125
126
127
128
129
130
131
132
133
# File 'main.rb', line 125

def require_all
  count = 0
  Dir.glob( File.join(PATH, '*.{rb, rbs}') ).each { |fpath|
    base_name = File.basename(fpath)
    next if base_name == BASE || !REGISTERED_FILES.include?(base_name)
    count += 1 if Kernel.require(fpath)
  }
  count
end