module SolveBio::CLI::Tutorial

Public Class Methods

tutorial() click to toggle source
# File lib/solvebio/cli/tutorial.rb, line 4
def tutorial
    tutorial_file = File.join(File.dirname(__FILE__), "tutorial.md")
    less = which('less') 
    if less
        exec less + ' ' + tutorial_file
    else
        puts File.read(tutorial_file)
        puts
        puts "#######################################################################"
        puts
        puts "Warning: 'less' command not found in $PATH."
        puts "Read the tutorial online at https://www.solvebio.com/docs/ruby-tutorial"
        puts
        puts "#######################################################################"
        puts
    end
end

Public Instance Methods

which(cmd) click to toggle source
# File lib/solvebio/cli/tutorial.rb, line 23
def which(cmd)
    exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
    ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
        exts.each { |ext|
            exe = File.join(path, "#{cmd}#{ext}")
            return exe if File.executable?(exe) && !File.directory?(exe)
        }
    end
    return nil
end

Private Instance Methods

tutorial() click to toggle source
# File lib/solvebio/cli/tutorial.rb, line 4
def tutorial
    tutorial_file = File.join(File.dirname(__FILE__), "tutorial.md")
    less = which('less') 
    if less
        exec less + ' ' + tutorial_file
    else
        puts File.read(tutorial_file)
        puts
        puts "#######################################################################"
        puts
        puts "Warning: 'less' command not found in $PATH."
        puts "Read the tutorial online at https://www.solvebio.com/docs/ruby-tutorial"
        puts
        puts "#######################################################################"
        puts
    end
end