class Grouik::Loadable

Describe a loable item (Ruby file)

Attributes

base[R]
basedir[R]
path[R]

Public Class Methods

new(base, path, basedir = '.') click to toggle source

@param [String] base @param [String] path @param [String] basedir

# File src/lib/grouik/loadable.rb, line 12
def initialize(base, path, basedir = '.')
  @base = Pathname.new(base)
  @path = path
  @basedir = Pathname.new(basedir).realpath
end
paths() click to toggle source

@return [Array<String>]

# File src/lib/grouik/loadable.rb, line 47
def paths
  $LOAD_PATH.map(&:to_s)
end

Public Instance Methods

load(from = nil) click to toggle source

@return [Boolean]

# File src/lib/grouik/loadable.rb, line 35
def load(from = nil)
  path = from ? Pathname.new(from).join(self.path) : self.path

  return require path
end
loadable?() click to toggle source
# File src/lib/grouik/loadable.rb, line 41
def loadable?
  self.class.paths.include?(basedir.join(base).to_s)
end
to_s() click to toggle source

@return [String]

# File src/lib/grouik/loadable.rb, line 30
def to_s
  path(true)
end