Module: RequireDir

Extended by:
Forwardable, RequireDir
Included in:
RequireDir
Defined in:
lib/require_dir.rb,
lib/require_dir/loader.rb,
lib/require_dir/version.rb

Defined Under Namespace

Classes: Loader

Constant Summary collapse

VERSION =
'0.1.2'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loaderObject

Returns the value of attribute loader.



5
6
7
# File 'lib/require_dir.rb', line 5

def loader
  @loader
end

Instance Method Details

#init(source, options = {}) ⇒ Object



18
19
20
# File 'lib/require_dir.rb', line 18

def init(source, options = {})
  init_with_offset(source, 0, options)
end

#init_with_offset(source, offset = 0, options = {}) ⇒ Object Also known as: init_from_source



13
14
15
16
# File 'lib/require_dir.rb', line 13

def init_with_offset(source, offset = 0, options = {})
  project_folder = project_folder_from(source: source, offset: offset)
  self.loader = RequireDir::Loader.new(project_folder, options)
end

#project_folder_from(source:, offset: 0) ⇒ Object



7
8
9
10
11
# File 'lib/require_dir.rb', line 7

def project_folder_from(source: , offset: 0)
  dirs_up = ''
  offset.times { dirs_up << '/..' } if offset > 0
  File.dirname(File.expand_path(source +  dirs_up))
end