Class: Versions

Inherits:
Object
  • Object
show all
Extended by:
Configurable, Versionable
Includes:
ClassHelpers, FileHelpers
Defined in:
lib/versions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(mod) ⇒ Object

Public: Sets up and returns a new instance

mod - Symbol or String of the library name

Returns an instance of Versions



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

def self.for(mod)
  new(mod)
end

Instance Method Details

#at(path) ⇒ Object

Public: Sets the base directory for this instance

path - path to the directory

Returns self



27
28
29
30
# File 'lib/versions.rb', line 27

def at(path)
  @path = path
  self
end

#available?(version) ⇒ Boolean

Public: Whether a version is available or not

version - a version string

Returns a Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/versions.rb', line 51

def available?(version)
  !!mapped_versions[version]
end

#select(version) ⇒ Object

Public: Selects a version

version - a version string

Returns the versioned Class Raises VersionNotAvailableError



38
39
40
41
42
43
44
# File 'lib/versions.rb', line 38

def select(version)
  if file = mapped_versions[version]
    load_class(version, file)
  else
    raise VersionNotAvailableError.new "Version #{version} is unavailable."
  end
end

#versionsObject

Public: Get the available versions

Returns an Array of version strings



58
59
60
# File 'lib/versions.rb', line 58

def versions
  mapped_versions.keys.sort
end