class RBT::FindAlternativeArchive

Constants

DEFAULT_ARGUMENT
#

DEFAULT_ARGUMENT

#
NAMESPACE
#

NAMESPACE

#

Public Class Methods

[](i = '') click to toggle source
#

RBT::FindAlternativeArchive[]

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 183
def self.[](i = '')
  self.new(i)
end
new( commandline_arguments = DEFAULT_ARGUMENT, run_already = true ) click to toggle source
#

initialize

The first argument should be the full, “expected” path to our archive in question. We need this full path so that this class can replace it with a proper new path, if necessary.

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 44
def initialize(
    commandline_arguments = DEFAULT_ARGUMENT,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

archive_type()
Alias for: archive_type?
archive_type?() click to toggle source
#

archive_type?

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 76
def archive_type? # Return the archive type here.
  return DetermineArchiveType[path?]
end
Also aliased as: archive_type
check_for_other_archive_types()
commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 162
def commandline_arguments?
  @commandline_arguments
end
Also aliased as: input?
determine_directory_name() click to toggle source
#

determine_directory_name

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 106
def determine_directory_name
  @directory_name = rds("#{File.dirname(@file_path)}/")
end
determine_file_path() click to toggle source
#

determine_file_path

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 96
def determine_file_path
  set_file_path(
    @commandline_arguments.first
  )
  determine_directory_name
end
file_path?() click to toggle source
#

file_path?

This method will return the file path.

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 85
def file_path?
  @file_path
end
Also aliased as: path?, path, results?, result?, result
filename?() click to toggle source
#

filename?

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 120
def filename?
  remove_file_suffix(
    @file_path
  )
end
find_other_archive(i) click to toggle source
#

find_other_archive

The input to this method should be a version, as a number.

The method will then try to find other archives.

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 152
def find_other_archive(i)
  i = i.to_f unless i.is_a? Float
  _ = return_alternative_archives.select {|entry| entry =~ /#{i}/ }
  return _.first unless _.empty?
  nil # else we will return nil.
end
has_alternative?() click to toggle source
#

has_alternative?

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 169
def has_alternative?
  return true unless return_alternative_archives.empty?
end
Also aliased as: more_than_one_entry?
input?()
more_than_one_entry?()
Alias for: has_alternative?
path()
Alias for: file_path?
path?()
Alias for: file_path?
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 58
def reset
  super()
end
result()
Alias for: file_path?
result?()
Alias for: file_path?
results?()
Alias for: file_path?
return_alternative_archives() click to toggle source
#

return_alternative_archives

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 139
def return_alternative_archives
  return_default_files.select {|entry|
    is_an_archive? entry
  }
end
return_default_files(from = " click to toggle source
#

return_default_files

Return the default files from the @directory_name entry. Note that we will not traverse into subdirectories.

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 132
def return_default_files(from = "#{@directory_name}*")
  Dir[from]
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 176
def run
  determine_file_path
end
set_commandline_arguments(i = '') click to toggle source
#

set_commandline_arguments

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 65
def set_commandline_arguments(i = '')
  i = [i].flatten.compact
  if i.empty?
    i << DEFAULT_ARGUMENT
  end
  @commandline_arguments = i
end
set_file_path(i) click to toggle source
#

set_file_path

#
# File lib/rbt/utility_scripts/find_alternative_archive.rb, line 113
def set_file_path(i)
  @file_path = i
end