class RBT::Prefix
Constants
- DEFAULT_PREFIX
- USR_PREFIX
#¶ ↑
USR_PREFIX
¶ ↑#¶ ↑
Public Class Methods
new( optional_use_this_program_name = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 40 def initialize( optional_use_this_program_name = nil, run_already = true ) reset # Must always come first. if optional_use_this_program_name set_original_input(optional_use_this_program_name) set_program(optional_use_this_program_name) end if block_given? yielded = yield case yielded when :ntrad set_prefix(:ntrad) else run if run_already end else run if run_already end end
Public Instance Methods
<<(i)
click to toggle source
assign_prefix(i)
click to toggle source
#¶ ↑
assign_prefix
¶ ↑
Simply assign the prefix, without any further checking.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 218 def assign_prefix(i) case i when :default, nil i = DEFAULT_PREFIX end i = i.dup if i.frozen? i.strip! i << '/' unless i.end_with? '/' @prefix = i end
Also aliased as: assign_prefix=, use_this_prefix
eliminate_hyphens()
click to toggle source
empty?()
click to toggle source
end_with?(i)
click to toggle source
include?(i)
click to toggle source
prefix?()
click to toggle source
program?()
click to toggle source
reset()
click to toggle source
return_non_traditional_prefix(i)
click to toggle source
#¶ ↑
return_non_traditional_prefix
¶ ↑
This method will return a proper non-traditional prefix.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 148 def return_non_traditional_prefix(i) program_information = ::ProgramInformation::ProgramInformation.new(i, true, @be_verbose ) # bl $RUBY_COOKBOOKS/lib/cookbooks/program_information.rb name = program_information.name.to_s.capitalize.delete('-_').capitalize version = program_information.version i = "#{programs_dir?}#{name}/#{version}/".dup # This has the version name i << '/' unless i.end_with? '/' # ======================================================================= # # As of May 2014 we get rid of all '-'. # ======================================================================= # i.delete!('-') if i.include? '-' return i # This here should usually return a string like "/Programs/Htop/1.1.0" end
run()
click to toggle source
set_original_input(i)
click to toggle source
set_prefix( i = program? )
click to toggle source
#¶ ↑
set_prefix
¶ ↑
This methods assigns to the instance variable @prefix which keeps the prefix in use. The prefix instance variable is stored in the variable @prefix.
Input should include the version, i.e. “htop-1.0” would be a proper input.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 181 def set_prefix( i = program? ) i = USR_PREFIX if i == 'def' case i.to_s # case tag when 'gobolinux','gobolinux_prefix','ntrad','false', 'default','app_dir_like', /^app(_|-)?dir/ i = return_non_traditional_prefix(program?) # defined in this file here. # ===================================================================== # # As of May 2014 we get rid of all '-' # ===================================================================== # i.delete!('-') if i.include? '-' when 'true','t','trad','traditional','tra' # True means "usr" prefix. i = USR_PREFIX else # Else default to USR_PREFIX. # i = USR_PREFIX end assign_prefix(i) # Now, simply assign it here. end
set_program(i = nil)
click to toggle source
#¶ ↑
set_program
¶ ↑
Use this method to set the instance variable @program. It shall be kept like that. The input can contain a '-'.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 128 def set_program(i = nil) case i when :trad set_prefix(i) end @program = i # Can contain something like htop. end
Also aliased as: assign
strip!()
click to toggle source
sub!(old, new)
click to toggle source
use_non_traditional_prefix()
click to toggle source
#¶ ↑
use_non_traditional_prefix
¶ ↑
This method will assign to a non-traditional (gobolinux) prefix.
#¶ ↑
# File lib/rbt/prefix/prefix.rb, line 209 def use_non_traditional_prefix set_prefix(:gobolinux) end
Also aliased as: gobolinux_prefix