Class: Roebe::Base

Inherits:
Object show all
Includes:
CommandlineArguments
Defined in:
lib/roebe/base/env.rb,
lib/roebe/base/run.rb,
lib/roebe/base/base.rb,
lib/roebe/base/copy.rb,
lib/roebe/base/misc.rb,
lib/roebe/base/next.rb,
lib/roebe/base/opnn.rb,
lib/roebe/base/simp.rb,
lib/roebe/base/time.rb,
lib/roebe/base/chdir.rb,
lib/roebe/base/reset.rb,
lib/roebe/base/editor.rb,
lib/roebe/base/colours.rb,
lib/roebe/base/esystem.rb,
lib/roebe/base/symlink.rb,
lib/roebe/base/encoding.rb,
lib/roebe/base/constants.rb,
lib/roebe/base/prototype.rb,
lib/roebe/base/is_on_roebe.rb,
lib/roebe/base/verbose_truth.rb,
lib/roebe/base/write_what_into.rb,
lib/roebe/base/commandline_arguments.rb,
lib/roebe/base/home_directory_of_user_x.rb,
lib/roebe/base/support_for_beautiful_url.rb

Overview

Roebe::Base

Direct Known Subclasses

AddIrcQuote, AddNewlineAfter, AddNewlineAfterNCharacters, AddThisUserToTheSudoersFile, AddTwoBinaryNumbers, AddUserLighty, AggregateAllFilesTogetherFromThisDirectory, Aliases, AllGames, AllMyGems, Alltagsgeschichte, AlphabeticalSorter, Anteile, ApacheConfigurationMaker, AppendThis, AppendToLine, At, AudioInformation, AutoRenameFileBasedOnItsCreationDate, AutoRenameFileBasedOnTimeToday, Autodater, AutomountUSB, Automounter, AvailableClasses, BackupCoreSystem, BasicConfigure, BatchGenerateAllMyGems, BecomeAnotherUser, Bezirk, BirthdayNotifications, Books, Browser, BurnISO, CSS_Analyzer, CaesarCipher, Calendar, CalendarMaker, Cat, CelsiusToFahrenheit, CheckForBadBlocks, CheckYaml, ChmodCurrentTime, Clipboard, Clock, ColourizeNumbers, CompareTheseTwoDirectories, CompareTheseTwoFiles, CompileKernel, ConfigGenerator, Conky, ConkyRcfileGenerator, ConvertEncodingOfThisFile, ConvertFileIntoUtfEncoding, ConvertThisCgiFileIntoASinatrafiedApplication, CopyFromGlibc, CopyHere, CopyKernelConfig, CopyTheseDirectoriesTo, CorrectGibberish, CountCharacters, CovidLethality, CreateAsoundrcFile, CreateBenchmarkFile, CreateBootableUSB, CreateDesktopFile, CreateDocbookSgmlDtdCatalog, CreateFileSkeleton, CreateFirefoxExtension, CreateISO, CreateIsoForGames, CreateJarArchive, CreateLocalImagesYamlFile, CreateMyDirectories, CreateRubyDirectoryLayout, CreateZip, CurrentMonitorResolution, CurrentTimeInSingapore, CutAfterColon, CuteEmoji, Daemonize, DateSort, DayCalendar, Dbus, DeleteAllDirectories, DeleteEmptyFiles, DhcpcdWrapper, DifferencesBetweenTwoDirectories, Disable, DisplayGccVersion, DisplayWeekdays, DoAGoogleSearch, DoInstall, Done, DoneAndOpen, DoskeyGenerator, DowncaseDirectories, DowncaseExtension, DownloadFromThisUrl, DuplicateFiles, Eduroam, Email, Empty, Enable, EnableAutologin, EnglishToGerman, Ethernet, EuclidianDistance, ExtractDocumentation, ExtractGemFile, FeetToCentimetres, FetchUrl, FileFilter, FileParser, FileRenamer, FilesThatCouldBecomeApps, FilterApacheLog, FindAllFilesEncodedInISO, FindAllFilesWithAQuestionMark, FindDuplicateEntriesInAliasFile, FindEmptyFiles, FindExpandedAlias, FindOutVersionOf, FindStaticLibraries, FinishedBooks, FixMcookie, FixMissingNumbersForAsciiParadise, FixTimezone, FontInstaller, FotoSearcher, FotosFürIngrid, FragmentMaker, GUI::Calculator, GUI::PingWidget, GUI::SimpleClock, GUI::UniversalWidgets::CodeGenerator, GUI::UniversalWidgets::GenerateXorgConfiguration, GUI::UniversalWidgets::Ifconfig, GUI::UniversalWidgets::Md5Comparer, GUI::UniversalWidgets::MicrosoftController, GUI::UniversalWidgets::SendEmail, GUI::UniversalWidgets::Shell, GUI::UniversalWidgets::ShowAliases, GUI::UniversalWidgets::ShowTenAliases, GUI::UniversalWidgets::SystemWidget, GUI::UniversalWidgets::TaskViewer, GUI::UniversalWidgets::TodoViewer, GUI::UniversalWidgets::ViewImage, GUI::UniversalWidgets::WlanInformationCenter, GUI::UniversalWidgets::WorldCapitals, GeneralOverviewer, GenerateAlsaConf, GenerateDosboxConfig, GenerateEtcResolvConfFile, GenerateEtcShellFile, GenerateFluxboxAppsFile, GenerateFluxboxKeysFile, GenerateFstabFile, GenerateGemspec, GenerateGrubConfig, GenerateLocales, GenerateLsColors, GenerateMasterShellScript, GenerateNanoConfig, GenerateNsswitchConf, GenerateOverviewOfTheLocallyAvailableBooks, GenerateProtocols, GenerateRewriteRules, GenerateRtfFile, GenerateSystemValues, GenerateUnitFiles, GenerateXauthorityFile, GenerateXorgConf, GetDependencies, Github, GoodNight, GoogleUrlCleaner, GrantSuperuserRights, GrubAppender, GrubConfigGenerator, GzipThisFile, HandleLightppd, HandleQuicktipps, HelloWorld, HexToRGB, Holiday, HostsAppender, HtmlFormFetcher, IPaste, IcewmKeysGenerator, Identical, Imdb, In, IncrementApplicationVersion, Inhalt, Inputrc, InstallDebianFile, InstallFlash, InstallLibreoffice, InstallMyGems, InstallOpensslCertificates, InstallRubyProject, InstallThisKonsoleTheme, InstallWrapper, InteractiveFileCreator, Into, IsoToUsb, JavaHeader, JavaRunner, KdeKonsole, KdeKonsoleSendCommand, KeyValueParser, KeysGenerator, KillFirefox, KillPalemoon, KonsoleNewTab, LastCalledLogger, LastLine, LeftHyphenInThisFile, LevelSubdirectories, LighttpdConfigGenerator, LiloConfigGenerator, LinePadder, Log10, MakeCookbooksGem, MakeGem, ManipulateQuotes, MarkThisDirectory, MarriedWithChildren, Mbl, MealMaker, Menu::Generator, Merge, ModifyShebangHeader, Modright, MonthlyActivityOnRubygems, MountDVD, MountIsoFile, MoveContentOfThisDirectoryToThatDirectoryUnlessTargetAlreadyExists, MoveFile, MoveMouse, Mrxvt, MrxvtOptions, MyDefaultWebrickServer, MyIp, NDirectories, NDownloadsOnRubygemsOrg, NFiles, NFotos, NGemsExistInTotal, NSymlinks, NcursesTerminal, NibbleConverter, NonSymlinks, NumberFiles, NumberToEnglish, Nutrition, Nvidia, ObtainAudioRecordingsFromVoiceRecorder, OnScreenDisplay, OneLinePasswords, OpenPDF, OpenRandomBook, OutputRandomLine, OutputTextThenAssignToTheXorgBuffer, PackageJavaCompiler, PadViaQuotes, ParagraphOntoOneLine, ParseApacheLog, PascalschesDreieck, Passwords, PathGenerator, PercentageCounter, PermissionAsciiFormat, PhpToRuby, PoundToKgConverter, PrependThis, PrependThisLineToThatFile, PrependThisStringToEveryLineOfThisFile, PrependTodaysDate, Primfaktorzerlegung, PristineGems, ProperEnglish, PublishGem, PullTogether, PurgeFilesOrDirectories, PutAllGemsIntoThisProject, Qemu, QueryWorldTime, Quiz, RXinitrc, Ram, RandomBackground, RandomOpen, Rbashrc, Rdate, ReadmeGenerator, RegelVonSarrus, RemoteGems, RemoveBadFluxboxStyles, RemoveComments, RemoveDirectory, RemoveDuplicateLines, RemoveExtension, RemoveFileExtension, RemoveGems, RemoveLightyLogs, RemoveLine, RemoveLocalhost, RemoveMissing, RemoveNewlines, RemoveSoloNumbers, RemoveThisSubstringFromAllFiles, RenameMateTerminal, ReplaceGlobalVariablesInThisFile, ReplaceSpaceWithUnderscore, ReplaceWhatWith, ReportHowManyClassesExistForThisDirectory, ReportHowManyFilesAreInThisDirectory, ReportSameNamedFiles, RequireEverything, RestoreKde, ReturnNAliases, ReturnRandomImage, RomanNumberConverter, RubyCat, RubyHeader, RubyMain, RubyNano, RubySeq, RubyUseConfigFile, RubyVersionSwitcher, Run, RunEachLineAsEsystem, SanitizeThisBookPath, ScanForHttpLinks, Schlafe, SendEmail, ServeLocalPage, SetAliases, SetBackground, SetChained, SetCurrentISO, SetHardwareClock, SetHwclock, SetNormalAliasTo, SetXfceWallpaper, SetupChrootedEnvironment, Shell, Shell::ColourizedHelpLine, Shell::Commandline, ShowAppointments, ShowAvailableFonts, ShowAvailableUsers, ShowKernelModules, ShowNonSymlinks, ShowOnlyFiles, ShowPrimeNumbers, ShowSigint, ShowTenAliases, ShowTwentyAliases, SimpleBootScript, SimpleExtractor, SimpleMarkdownParser, SizeOf, SizeOfStates, SkelMaker, Slogans, SlowLoad, SortedOutput, Sourcerank, SpecialSymlink, StartProgram, StdRenamer, Stories::Stories, Story, SumOfAllNumbers, Supermerger, SymlinkAllDirectoriesInThisDirectory, SymlinkDirectoriesFromThatDirectoryToTheCurrentDirectory, SymlinkDirectory, SymlinkEverythingFromThatDirectoryToThisDirectory, SymlinkFilesFromThatDirectoryToTheCurrentDirectory, SyntaxChecker, SystemChecker, TakeScreenshot, TalesFromTheCrypt, TelnetWrapper, TerminalPS1, TestForPsych, TestOpenssl, TestYaml, TheCollatzProblem, ThresholdSplitter, TicTacToe, ToBinary, ToBuy, ToNext, ToSquashfs, ToUtf, Today, TodoOverview, TodoSanitizer, TopTenAliases, TotalPagesInFinishedBooks, Translate, TraurigeOderFröhlicheZahl, TraverseInstall, Treeview, TrivialTimeParser, TurnRubyFileIntoGem, TwentyfourHoursNotation, UmlautConverter, Undone, UnicodeSnowman, UnifiedPadding, Unrar, Upcaser, Update, UpdateStaticHtmlPagesInTheDirectoryContainingMyFotos, UploadToImgur, UpwardsCounter, Usage, UsbDevices, UseJruby, ValidateRoeberiaEnvironmentVariables, VteStarter, Wallpaper, WaylandOrXorgserver, WebfancyController, Wikipedia, Windows::Powershell, Wlan, WochentagAnzeiger, WriteWhatInto, YamlCheck, YoutubeDownloader, Zenity, Zoll

Defined Under Namespace

Modules: CommandlineArguments

Constant Summary collapse

COLOURS =
::Colours
N =
#

N

#
"\n"
NAMESPACE =
#

NAMESPACE

#
inspect
HOME_DIRECTORY_OF_USER_X =
#

HOME_DIRECTORY_OF_USER_X

This constant is only useful on my home system.

#
Roebe::HOME_DIRECTORY_OF_USER_X

Instance Method Summary collapse

Methods included from CommandlineArguments

#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(run_already = true) ⇒ Base

#

initialize

#


38
39
40
41
42
43
# File 'lib/roebe/base/prototype.rb', line 38

def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Instance Method Details

#actions(i = nil, &block) ⇒ Object Also known as: action

#

actions (actions tag, action tag)

#


60
61
62
63
64
# File 'lib/roebe/base/misc.rb', line 60

def actions(
    i = nil, &block
  )
  Roebe.actions(i, &block)
end

#append_this_onto_that_file(this, that_file) ⇒ Object Also known as: append_what_to_this_file

#

append_this_onto_that_file

#


27
28
29
30
31
# File 'lib/roebe/base/write_what_into.rb', line 27

def append_this_onto_that_file(
    this, that_file
  )
  Roebe.append_this_onto_that_file(this, that_file)
end

#append_what_into(what, into) ⇒ Object Also known as: append_what_onto

#

append_what_into

#


176
177
178
# File 'lib/roebe/base/prototype.rb', line 176

def append_what_into(what, into)
  Roebe.append_what_into(what, into)
end

#be_silentObject Also known as: be_quiet, set_be_quiet, do_not_be_verbose

#

be_silent

#


522
523
524
# File 'lib/roebe/base/prototype.rb', line 522

def be_silent
  set_be_verbose(:be_silent)
end

#be_verbose?Boolean Also known as: verbose?

#

be_verbose?

#

Returns:

  • (Boolean)


515
516
517
# File 'lib/roebe/base/prototype.rb', line 515

def be_verbose?
  @be_verbose
end

#beautiful_url(i) ⇒ Object Also known as: prettify_this_url, prettify_url, sanitize_url

#

beautiful_url

#


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/roebe/base/support_for_beautiful_url.rb', line 14

def beautiful_url(i)
  unless Object.const_defined? :BeautifulUrl
    require 'beautiful_url/requires/failsafe_require_of_beautiful_url.rb'
  end
  _ = i.dup
  _ = BeautifulUrl[_]
  if _.is_a? Array
    _ = _.first
  end
  _
end

#burlywood(i = '', use_colours = @use_colours) ⇒ Object

#

burlywood

#


418
419
420
421
422
423
424
# File 'lib/roebe/base/colours.rb', line 418

def burlywood(
    i           = '',
    use_colours = @use_colours
  )
  return COLOURS.burlywood(i) if use_colours
  return i
end

#call_next(i = 'exams') ⇒ Object

#

call_next

#


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/roebe/base/next.rb', line 16

def call_next(i = 'exams')
  case i
  # ======================================================================= #
  # === exam
  # ======================================================================= #
  when 'exam',
       'exams',
       'exam?',
       'default'
    Studium::Exams::NextExam.new
  end
end

#chdir(i) ⇒ Object Also known as: cd, cd_to_this_directory, change_directory

#

chdir

Change directory to the target given via this method. The input to this method should be a String representing a directory, such as “/tmp/”.

#


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roebe/base/chdir.rb', line 18

def chdir(i)
  if i.is_a? Array
    i = i.join(' ').strip
  end
  # ======================================================================= #
  # Allow for some symbol-shortcuts here.
  # ======================================================================= #
  case i # case tag
  # ======================================================================= #
  # === :home_dir
  # ======================================================================= #
  when :home_dir,
       :home
    i = rds(ENV['HOME'].to_s+'/')
  # ======================================================================= #
  # === :ruby_src_dir
  # ======================================================================= #
  when :ruby_src_dir
    i = RUBY_SRC
  # ======================================================================= #
  # === :log_directory
  # ======================================================================= #
  when :log_directory
    i = ::Roebe.log_directory?
  end
  Dir.chdir(i) if File.directory? i
end

#cheerful_guyObject Also known as: cheering_person, return_cheering_person

#

cheerful_guy

This is a “cheerful guy”, in ASCII, which can be output on the commandline, indicating that some operation has run successfully.

#


274
275
276
# File 'lib/roebe/base/misc.rb', line 274

def cheerful_guy
  "\\o/"
end

#cliner(use_this_token = '*') ⇒ Object

#

cliner

#


29
30
31
32
33
# File 'lib/roebe/base/misc.rb', line 29

def cliner(
    use_this_token = '*'
  )
  ::Cliner.cliner(use_this_token)
end

#complex_esystem(i, optional_colourize = true, default_colour = :steelblue, use_this_padding = ' ', &block) ⇒ Object Also known as: esystem, raw_esystem, esystem_colourized, esystem_colourize

#

complex_esystem

This method was written in June 2023 to work around a strange bug.

Since June 2023 the method will try to automatically colourize the given command.

#


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/roebe/base/esystem.rb', line 34

def complex_esystem(
    i,
    optional_colourize = true,
    default_colour     = :steelblue,
    use_this_padding   = '  ',
    &block
  )
  begin
    require 'colours/autogenerated/html_colours_methods.rb'
  rescue LoadError; end
  case optional_colourize
  # ======================================================================= #
  # === :do_colourize
  # ======================================================================= #
  when :do_colourize,
       :colourize
    optional_colourize = true
  # ======================================================================= #
  # === :do_colourize_and_pad_the_system_command
  # ======================================================================= #
  when :do_colourize_and_pad_the_system_command
    optional_colourize = true
    use_this_padding   = '  ' # Use slightly more padding here.
  end
  if i.is_a? Array
    i.each {|entry|
      complex_esystem(
        entry,
        optional_colourize,
        default_colour,
        use_this_padding,
        &block
      )
    }
  else
    i = i.dup if i.frozen?
    i.strip! if i
    real_cmd_to_use = i.dup
    # ===================================================================== #
    # === Handle Blocks next
    # ===================================================================== #
    if block_given? # === Support colours
      yielded = block.call # or yield.
      # =================================================================== #
      # === Handle Hashes next
      # =================================================================== #
      if yielded.is_a? Hash
        if yielded.has_key? :colour
          yielded = yielded.delete(:colour)
        end
      else # else assume Symbols here
        case yielded
        # ================================================================= #
        # === :colourize_first_word_differently
        #
        # This entry point will colourize the first word differently.
        # ================================================================= #
        when :colourize_first_word_differently
          if i.include?(' ')
            splitted = i.split(' ')
            first_word = lightblue(splitted.first)
            i = first_word+' '+
                ::Colours::HtmlColoursMethods.send(
                  default_colour.to_sym,
                  splitted[1..-1].join(' ')
                )
            optional_colourize = false
          end
        # ================================================================= #
        # === :do_colourize
        # ================================================================= #
        when :do_colourize,
             :colourize
          optional_colourize = true
          yielded = default_colour
        end
      end
    end
    i = i.to_s if i.is_a? Symbol
    i = i.dup if i.frozen?
    e
    # i = "#{i} #{ERROR_LINE}"
    if real_cmd_to_use.include?('& 2>&1')
      real_cmd_to_use.sub!(/& 2>&1/,'2>&1 &')
    end
    if optional_colourize
      e "#{rev}#{use_this_padding}#{::Colours::HtmlColoursMethods.send(default_colour, i)}"
    else
      e "#{rev}#{use_this_padding}#{i}"
    end
    # ===================================================================== #
    # Next run the sys-command.
    # ===================================================================== #
    _result = `#{real_cmd_to_use}`
    if _result.include?(': command not found')
      e tomato("The command #{i} was not found.")+rev
      return false
    else
      e _result # Show the result here.
      return true
    end
  end
end

#convert_global_env(i) ⇒ Object

#

convert_global_env

This method requires that the “convert_global_env” project is available.

#


18
19
20
# File 'lib/roebe/base/env.rb', line 18

def convert_global_env(i)
  return ConvertGlobalEnv[i]
end

#copy_directory(from, to = return_pwd) ⇒ Object Also known as: cpr

#

copy_directory

This method can be used to (recursively) copy a directory from one location to another. If remove_destination is true then FileUtils.copy_entry will remove each destination file before the copy-operation.

Documentation for FileUtils.copy_entry can be seen here:

https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html
https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html#method-c-copy_entry
#


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/roebe/base/copy.rb', line 30

def copy_directory(
    from,           # ← Source directory.
    to = return_pwd # ← Target directory.
  )
  case to
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default, nil
    to = return_pwd
  end
  remove_destination = true
  FileUtils.copy_entry(
    from,              # src
    to,                # dest
    false,             # preserve
    false,             # dereference_root
    remove_destination # remove_destination
  )
end

#copy_file(from, to) ⇒ Object Also known as: cp, copy, copy_files

#

copy_file

#


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/roebe/base/copy.rb', line 54

def copy_file(
    from, to
  )
  if from.is_a? Array
    from.each {|entry|
      copy_file(entry, to)
    }
  else
    if block_given?
      ::Roebe.copy_file(from, to) { yield }
    else
      ::Roebe.copy_file(from, to)
    end
  end
end

#cornflowerblue(i = '', use_colours = use_colours?) ) ⇒ Object

#

cornflowerblue

#


142
143
144
145
# File 'lib/roebe/base/colours.rb', line 142

def cornflowerblue(i = '', use_colours = use_colours?)
  return COLOURS.cornflowerblue(i) if use_colours
  return i
end

#create_directory(i, be_verbose = false) ⇒ Object

#

create_directory

#


131
132
133
134
135
136
137
138
139
# File 'lib/roebe/base/prototype.rb', line 131

def create_directory(
    i,
    be_verbose = false
  )
  if be_verbose
    e "Creating the directory `#{sdir(i)}` next."
  end
  ::Roebe.create_directory(i) # Simply delegate to this module-method.
end

#crimson(i = '', use_colours = use_colours?) ) ⇒ Object

#

crimson

#


246
247
248
249
# File 'lib/roebe/base/colours.rb', line 246

def crimson(i = '', use_colours = use_colours?)
  return COLOURS.crimson(i) if use_colours
  i
end

#current_month?Boolean

#

current_month?

This method here will return the long name of the current month.

For instance, during August we will return the String ‘August’ here.

#

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/roebe/base/time.rb', line 41

def current_month?
  Date::MONTHNAMES[
    get_current_month.to_s.to_i
  ].to_s
end

#current_time?Boolean Also known as: return_time

#

current_time?

This method will return a String such as “16:35:03”.

#

Returns:

  • (Boolean)


81
82
83
# File 'lib/roebe/base/time.rb', line 81

def current_time?
  ::Time.now.strftime '%H:%M:%S'
end

#current_year?Boolean Also known as: current_year, return_current_year

#

current_year?

This method will return a string, such as “2018” - thus denoting the current year.

#

Returns:

  • (Boolean)


22
23
24
# File 'lib/roebe/base/time.rb', line 22

def current_year?
  ::Time.now.strftime('%Y').dup
end

#cyan(i = '', use_colours = @use_colours) ⇒ Object

#

cyan

#


365
366
367
368
369
370
371
# File 'lib/roebe/base/colours.rb', line 365

def cyan(
    i           = '',
    use_colours = @use_colours
  )
  return COLOURS.cyan(i) if use_colours
  return i
end

#darkcyan(i = '', use_colours = use_colours? ) ⇒ Object

#

darkcyan

#


550
551
552
553
554
555
556
# File 'lib/roebe/base/colours.rb', line 550

def darkcyan(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.darkcyan(i) if use_colours
  return i
end

#darkgreen(i = '', use_colours = use_colours?) ) ⇒ Object

#

darkgreen

#


238
239
240
241
# File 'lib/roebe/base/colours.rb', line 238

def darkgreen(i = '', use_colours = use_colours?)
  return COLOURS.darkgreen(i) if use_colours
  i
end

#darkkhaki(i = '', use_colours = use_colours? ) ⇒ Object

#

darkkhaki

#


539
540
541
542
543
544
545
# File 'lib/roebe/base/colours.rb', line 539

def darkkhaki(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.darkkhaki(i) if use_colours
  return i
end

#darkslateblue(i = '', use_colours = use_colours?) ) ⇒ Object

#

darkslateblue

#


190
191
192
193
# File 'lib/roebe/base/colours.rb', line 190

def darkslateblue(i = '', use_colours = use_colours?)
  return COLOURS.darkslateblue(i) if use_colours
  return i
end

#deeppink(i = '', use_colours = @use_colours) ⇒ Object

#

deeppink

#


429
430
431
432
433
434
435
# File 'lib/roebe/base/colours.rb', line 429

def deeppink(
    i           = '',
    use_colours = @use_colours
  )
  return COLOURS.deeppink(i) if use_colours
  return i
end
#

This method can be used to remove symlinks.

#


23
24
25
26
27
# File 'lib/roebe/base/symlink.rb', line 23

def delete_symlink(i)
  if File.symlink? i
    delete_this_file(i)
  end
end

#do_not_use_the_base_coloursObject Also known as: do_not_use_colours, disable_colours

#

disable_colours

#


67
68
69
# File 'lib/roebe/base/colours.rb', line 67

def do_not_use_the_base_colours
  @use_colours = false
end

#do_use_the_base_coloursObject Also known as: enable_colours, do_use_colours

#

do_use_the_base_colours

The reason for this long, cumbersome name is so that we can always tap into this method, even if a downstream class overrides the “enable_colours()” and “do_use_colours()” method - which is the case for class Roebe::Shell, for instance.

#


59
60
61
# File 'lib/roebe/base/colours.rb', line 59

def do_use_the_base_colours
  @use_colours = true
end

#e(i = '') ⇒ Object Also known as: br

#

e (e tag)

Note that the alias br() to e() is experimental, as of October 2023.

#


421
422
423
# File 'lib/roebe/base/prototype.rb', line 421

def e(i = '')
  puts i
end

#ecomment(i, use_colours = use_colours? ) ⇒ Object

#

ecomment

#


619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
# File 'lib/roebe/base/colours.rb', line 619

def ecomment(
    i,
    use_colours = use_colours?
  )
  if i.is_a? Array
    ecomment(i, use_colours)
  else # since as of October 2022 we will handle colourized-comments in this method, as-is.
    if use_colours
      if i.include? '#'
        splitted = i.split('#')
        e "#{rev}"\
          "#{limegreen(splitted[0])}"\
          "#{orange('#')}"\
          "#{mediumpurple(splitted[1])}"
      else
        e i
      end
    else
      e i
    end
  end
end

#editor_to_use?Boolean Also known as: main_editor?

#

editor_to_use?

#

Returns:

  • (Boolean)


14
15
16
# File 'lib/roebe/base/editor.rb', line 14

def editor_to_use?
  Roebe.editor?
end

#efancy(i = '', use_colours = @use_colours) ⇒ Object

#

efancy

#


376
377
378
379
380
381
# File 'lib/roebe/base/colours.rb', line 376

def efancy(
    i           = '',
    use_colours = @use_colours
  )
  e sfancy(i, use_colours)
end

#eimp(i = '') ⇒ Object

#

eimp

#


21
22
23
# File 'lib/roebe/base/simp.rb', line 21

def eimp(i = '')
  e simp(i)
end

#emphasis(i) ⇒ Object

#

emphasis

#


645
646
647
# File 'lib/roebe/base/colours.rb', line 645

def emphasis(i)
  lightgreen(i)
end

#ensure_main_encoding(i) ⇒ Object

#

ensure_main_encoding

This currently defaults to the ISO-8859-1 encoding.

#


46
47
48
49
50
51
52
# File 'lib/roebe/base/encoding.rb', line 46

def ensure_main_encoding(i)
  if i.is_a? String
    i = i.dup if i.frozen?
    i = ::Roebe.ensure_main_encoding(i)
  end
  return i
end

#ensure_utf_encoding(i) ⇒ Object

#

ensure_utf_encoding

Ensure UTF/Unicode encoding of Strings through this method here.

#


30
31
32
33
34
35
36
37
38
39
# File 'lib/roebe/base/encoding.rb', line 30

def ensure_utf_encoding(i)
  if i.is_a? String
    # ===================================================================== #
    # Must check for frozen Strings first, though.
    # ===================================================================== #
    i = i.dup if i.frozen?
    i = i.force_encoding(::Roebe::Encoding::ENCODING_UTF)
  end
  i
end

#eparse(i = '', use_colours = use_colours? ) ⇒ Object

#

eparse

#


304
305
306
307
308
309
310
311
312
313
# File 'lib/roebe/base/colours.rb', line 304

def eparse(
    i           = '',
    use_colours = use_colours?
  )
  if use_colours
    COLOURS.eparse(i)
  else
    e i
  end
end

#erev(i = '') ⇒ Object

#

erev

#


612
613
614
# File 'lib/roebe/base/colours.rb', line 612

def erev(i = '')
  e "#{rev}#{i}"
end

#esteelblue(i) ⇒ Object

#

esteelblue

#


330
331
332
# File 'lib/roebe/base/colours.rb', line 330

def esteelblue(i)
  e steelblue(i)
end

#etomato(i = '', use_colours = use_colours?) ) ⇒ Object

#

etomato

#


127
128
129
# File 'lib/roebe/base/colours.rb', line 127

def etomato(i = '', use_colours = use_colours?)
  e tomato(i, use_colours)
end

#ewarn(i = '') ⇒ Object

#

ewarn

#


344
345
346
# File 'lib/roebe/base/colours.rb', line 344

def ewarn(i = '')
  e swarn(i)
end

#firebrick(i = '', use_colours = @use_colours) ⇒ Object

#

firebrick

#


407
408
409
410
411
412
413
# File 'lib/roebe/base/colours.rb', line 407

def firebrick(
    i           = '',
    use_colours = @use_colours
  )
  return COLOURS.firebrick(i) if use_colours
  return i
end

#get_current_dayObject Also known as: current_day?

#

get_current_day

This method will return a number from 1 to 31, representing the current time.

#


53
54
55
# File 'lib/roebe/base/time.rb', line 53

def get_current_day
  ::Time.now.strftime('%d').to_i
end

#get_current_monthObject Also known as: current_month_as_number?

#

get_current_month

#


30
31
32
# File 'lib/roebe/base/time.rb', line 30

def get_current_month
  ::Roebe::Time.get_current_month
end

#get_files_and_directories(i) ⇒ Object

#

get_files_and_directories

#


275
276
277
278
279
280
# File 'lib/roebe/base/prototype.rb', line 275

def get_files_and_directories(i)
  i = rds(i.dup)
  Dir[i].select {|entry|
    File.file?(entry) or File.directory?(entry)
  }.flatten.compact
end

#get_files_from(i = return_pwd, additional_modifiers = nil, &block) ⇒ Object Also known as: get_all_files_from, get_files

#

get_files_from

This method will return all files from the current directory.

#


287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/roebe/base/prototype.rb', line 287

def get_files_from(
    i                    = return_pwd,
    additional_modifiers = nil,
    &block
  )
  yielded = nil
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    additional_modifiers = yielded # This may have to be improved at a later time.
  end
  case i
  # ======================================================================= #
  # === :songs_directory
  #
  # This makes use of a hardcoded path.
  # ======================================================================= #
  when :songs_directory
    i = '/home/x/songs/*'
  end
  if additional_modifiers.is_a? Hash
    # ===================================================================== #
    # === :include_directories
    # ===================================================================== #
    if additional_modifiers.has_key?(:include_directories) and
       (additional_modifiers[:include_directories] == true)
      i = rds("#{i}/*")
    else
      i = rds("#{i}/*")
    end
  else
    case additional_modifiers
    # ===================================================================== #
    # === :ignore_subdirectories
    # ===================================================================== #
    when :ignore_subdirectories
      i = rds("#{i}/*")
    else # This entry-clause also covers input such as :include_directories
      i = rds("#{i}/**")
    end
  end
  all_results = Dir[i]
  result = all_results.select {|entry| File.file? entry }
  return result
end

#get_german_name_for_this_weekday(i) ⇒ Object Also known as: return_german_name_for_this_weekday

#

get_german_name_for_this_weekday

#


125
126
127
128
129
130
131
# File 'lib/roebe/base/time.rb', line 125

def get_german_name_for_this_weekday(i)
  wday = i.to_i
  # _ = return_utc
  # wday = _.wday
  this_day = DAY_NAMES[wday]
  return Roebe::WEEKDAYS_FROM_ENGLISH_TO_GERMAN[this_day]
end

#gold(i = '', use_colours = use_colours? ) ⇒ Object

#

gold

#


108
109
110
111
112
113
114
# File 'lib/roebe/base/colours.rb', line 108

def gold(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.gold(i) if use_colours
  return i
end

#green(i = '', use_colours = use_colours? ) ⇒ Object

#

green

#


601
602
603
604
605
606
607
# File 'lib/roebe/base/colours.rb', line 601

def green(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.green(i) if use_colours
  return i
end

#grey(i = '', use_colours = use_colours? ) ⇒ Object Also known as: grey?

#

grey

#


169
170
171
172
173
174
175
# File 'lib/roebe/base/colours.rb', line 169

def grey(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.grey(i) if COLOURS and COLOURS.respond_to?(:grey) and use_colours
  return i
end

#hh_mm_ss(i = ::Time.now) ⇒ Object Also known as: ss_mm_hh

#

hh_mm_ss

This will display the current time in hours:minutes:seconds.

There is also an alias for this, called ss_mm_hh, but that variant is wrong as name. Still, since my brain isn’t the best, I will retain that “wrong” alias as well.

#


142
143
144
145
146
# File 'lib/roebe/base/time.rb', line 142

def hh_mm_ss(
    i = ::Time.now
  )
  ::Roebe.hh_mm_ss(i)
end

#hh_mm_ss_day_month_year(i) ⇒ Object

#

hh_mm_ss_day_month_year

This method expects a time-object as its input.

#


171
172
173
# File 'lib/roebe/base/time.rb', line 171

def hh_mm_ss_day_month_year(i)
  hh_mm_ss(i).to_s+' '+dd_mm_yyyy(i).to_s
end

#home_dir?(i = ENV['HOME']) ⇒ Boolean

#

home_dir?

Just return the value of the environment HOME, for the home directory.

#

Returns:

  • (Boolean)


102
103
104
# File 'lib/roebe/base/misc.rb', line 102

def home_dir?(i = ENV['HOME'])
  "#{i}/".squeeze('/')
end

#home_directory_of_user_x?Boolean Also known as: home_dir_of_user_x?

#

home_directory_of_user_x?

#

Returns:

  • (Boolean)


23
24
25
# File 'lib/roebe/base/home_directory_of_user_x.rb', line 23

def home_directory_of_user_x?
  HOME_DIRECTORY_OF_USER_X
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#


317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/roebe/base/misc.rb', line 317

def infer_the_namespace
  _ = inspect
  if _.include?(':0x')
    _ = _.split(':0x').first.to_s.strip
  end
  _ = _.to_s.delete('<')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  @namespace = _.delete('#') # And assign it here.
end

#internal_hash?Boolean Also known as: ihash?

#

internal_hash?

#

Returns:

  • (Boolean)


308
309
310
# File 'lib/roebe/base/misc.rb', line 308

def internal_hash?
  @internal_hash
end

#is_a_directory?(i) ⇒ Boolean

#

is_a_directory?

#

Returns:

  • (Boolean)


511
512
513
# File 'lib/roebe/base/misc.rb', line 511

def is_a_directory?(i)
  i and File.directory?(i)
end

#is_a_file?(i) ⇒ Boolean

#

is_a_file?

#

Returns:

  • (Boolean)


504
505
506
# File 'lib/roebe/base/misc.rb', line 504

def is_a_file?(i)
  i and File.file?(i)
end

#is_a_jpg_file?(i) ⇒ Boolean

#

is_a_jpg_file?

#

Returns:

  • (Boolean)


232
233
234
# File 'lib/roebe/base/misc.rb', line 232

def is_a_jpg_file?(i)
  File.extname(i).delete('.') == 'jpg'
end

#is_an_image_file?(i) ⇒ Boolean Also known as: is_image_file?, is_an_image?

#

is_an_image_file?

#

Returns:

  • (Boolean)


70
71
72
# File 'lib/roebe/base/misc.rb', line 70

def is_an_image_file?(i)
  ::Roebe.is_image_file?(i)
end

#is_archive?(i) ⇒ Boolean

#

is_archive?

Determine whether the given input is an archive or whether it is not.

#

Returns:

  • (Boolean)


250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/roebe/base/misc.rb', line 250

def is_archive?(i)
  return_value = false
  if i.include? '/'
    i = File.basename(i)
  end
  case i
  when /\.xz$/,
       /\.tar$/,
       /\.zip$/,
       /\.tar.gz$/,
       /\.tar.bz2gz$/,
       /\.tar.xz$/,
       /\.gem$/
    return_value = true
  end
  return return_value
end

#is_audio_file?(i) ⇒ Boolean

#

is_audio_file?

This query-method can be used to determine whether the given argument (assumed to be a file) is an audio file or whether it is not. File extensions such as .mp3, .ogg or .wav are simply assumed to be audio files, as far as this method here is concerned.

Usage example:

"abc.wav".is_audio_file?
#

Returns:

  • (Boolean)


480
481
482
483
484
485
486
487
488
# File 'lib/roebe/base/misc.rb', line 480

def is_audio_file?(i)
  extension_name = File.extname(i).delete('.').downcase
  %w(
    mp3
    ogg
    wav
    m4a
  ).include? extension_name
end

#is_in_studium_dir?Boolean

#

is_in_studium_dir?

#

Returns:

  • (Boolean)


475
476
477
# File 'lib/roebe/base/prototype.rb', line 475

def is_in_studium_dir?
  return_pwd.include?(home_directory_of_user_x?+'studium')
end

#is_multimedia_file?(i) ⇒ Boolean Also known as: is_a_multimedia_file?

#

is_multimedia_file?

#

Returns:

  • (Boolean)


493
494
495
496
497
498
499
# File 'lib/roebe/base/misc.rb', line 493

def is_multimedia_file?(i) # combines both above
  if is_audio_file?(i) or is_video_file?(i)
    return true
  else
    return false 
  end
end

#is_on_roebe?Boolean Also known as: on_roebe?, is_roebe?

#

is_on_roebe?

Whether I am at home or whether I am not.

#

Returns:

  • (Boolean)


17
18
19
# File 'lib/roebe/base/is_on_roebe.rb', line 17

def is_on_roebe?
  ::Roebe.is_on_roebe?
end

#is_on_windows?Boolean Also known as: on_windows?, are_we_on_windows?

#

is_on_windows?

Use this to check if you are on windows or not.

#

Returns:

  • (Boolean)


284
285
286
287
288
289
290
291
# File 'lib/roebe/base/misc.rb', line 284

def is_on_windows?
  case RUBY_PLATFORM
  when /win/,/mingw/
    true
  else
    false
  end
end

#is_studium_available?Boolean

#

is_studium_available?

Method to query whether the studium gem is available or whether it is not.

#

Returns:

  • (Boolean)


345
346
347
# File 'lib/roebe/base/misc.rb', line 345

def is_studium_available?
  Object.const_defined?(:Studium)
end

#is_symlink?(i) ⇒ Boolean

#
#

Returns:

  • (Boolean)


14
15
16
# File 'lib/roebe/base/symlink.rb', line 14

def is_symlink?(i)
  File.symlink?(i)
end

#is_this_a_ruby_file?(this_file) ⇒ Boolean Also known as: is_this_file_a_ruby_file?

#

is_this_a_ruby_file?

This query method can be used to determine whether xyz is a ruby-file or whether it is not.

#

Returns:

  • (Boolean)


88
89
90
91
92
93
94
95
# File 'lib/roebe/base/misc.rb', line 88

def is_this_a_ruby_file?(this_file)
  _ = false # Our return value.
  first_line = File.open(this_file) {|f| f.readline }
  if first_line.include? 'bin/ruby' # Assumption is: "#!/usr/bin/ruby -w"
    _ = true
  end
  return _
end

#is_video_file?(i) ⇒ Boolean

#

is_video_file?

#

Returns:

  • (Boolean)


457
458
459
460
461
462
463
464
# File 'lib/roebe/base/misc.rb', line 457

def is_video_file?(i)
  extension_name = File.extname(i).delete('.').downcase
  %w(
    avi
    mp4
    ogm
  ).include? extension_name
end

#iso_encoding?Boolean Also known as: encoding?

#

iso_encoding?

#

Returns:

  • (Boolean)


21
22
23
# File 'lib/roebe/base/encoding.rb', line 21

def iso_encoding?
  ::Roebe::Encoding::ENCODING_ISO
end

#le(i = '') ⇒ Object

#

le

This is basically echo/puts, but with two ‘ ’ on the left side.

#


151
152
153
# File 'lib/roebe/base/misc.rb', line 151

def le(i = '')
  e "  #{i}"
end

#left_colour(i) ⇒ Object

#

left_colour

This method is typically used to colourize the part on the “left” side of a longer string, on the commandline. I did not want to keep using hardcoded colour-method names, which explains why this method was added at 20.10.2019.

#


323
324
325
# File 'lib/roebe/base/colours.rb', line 323

def left_colour(i)
  steelblue(i)
end

#lightblue(i = '', use_colours = use_colours? ) ⇒ Object

#

lightblue

#


451
452
453
454
455
456
457
# File 'lib/roebe/base/colours.rb', line 451

def lightblue(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.lightblue(i) if use_colours
  return i
end

#lightgreen(i = '') ⇒ Object

#

lightgreen

#


572
573
574
575
# File 'lib/roebe/base/colours.rb', line 572

def lightgreen(i = '')
  return COLOURS.lightgreen(i) if @use_colours
  return i
end

#lightseagreen(i = '', use_colours = use_colours? ) ⇒ Object

#

lightseagreen

#


580
581
582
583
584
585
# File 'lib/roebe/base/colours.rb', line 580

def lightseagreen(
    i = '', use_colours = use_colours?
  )
  return COLOURS.lightseagreen(i) if use_colours
  return i
end

#lightsteelblue(i = '', use_colours = use_colours? ) ⇒ Object

#

lightsteelblue

#


473
474
475
476
477
478
479
# File 'lib/roebe/base/colours.rb', line 473

def lightsteelblue(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.lightsteelblue(i) if use_colours
  return i
end

#lime(i = '', use_colours = use_colours?) ) ⇒ Object

#

lime

#


198
199
200
201
# File 'lib/roebe/base/colours.rb', line 198

def lime(i = '', use_colours = use_colours?)
  return COLOURS.lime(i) if use_colours
  return i
end

#limegreen(i = '', use_colours = use_colours? ) ⇒ Object

#

limegreen

#


590
591
592
593
594
595
596
# File 'lib/roebe/base/colours.rb', line 590

def limegreen(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.limegreen(i) if use_colours
  return i
end

#localhost_to_data(i) ⇒ Object

#

localhost_to_data

#


124
125
126
127
128
129
130
131
132
# File 'lib/roebe/base/misc.rb', line 124

def localhost_to_data(i)
  if i.include? 'localhost'
    i.sub!(
      /^http:\/\/localhost\//,
      '/home/x/'
    )
  end
  return i
end

#log_directory?Boolean Also known as: log_dir?

#

log_directory?

This method wraps over the toplevel method Roebe.log_directory?().

#

Returns:

  • (Boolean)


399
400
401
# File 'lib/roebe/base/misc.rb', line 399

def log_directory?
  ::Roebe.log_directory?
end

#main_encoding?Boolean

#

main_encoding?

#

Returns:

  • (Boolean)


14
15
16
# File 'lib/roebe/base/encoding.rb', line 14

def main_encoding?
  ::Roebe::Encoding::MAIN_ENCODING_TO_USE
end

#mediumorchid(i = '', use_colours = use_colours?) ) ⇒ Object

#

mediumorchid

#


270
271
272
273
# File 'lib/roebe/base/colours.rb', line 270

def mediumorchid(i = '', use_colours = use_colours?)
  return COLOURS.mediumorchid(i) if use_colours
  return i
end

#mediumpurple(i = '', use_colours = use_colours? ) ⇒ Object

#

mediumpurple

#


528
529
530
531
532
533
534
# File 'lib/roebe/base/colours.rb', line 528

def mediumpurple(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.mediumpurple(i) if use_colours
  return i
end

#mediumseagreen(i = '', use_colours = use_colours? ) ⇒ Object

#

mediumseagreen

#


484
485
486
487
488
489
490
# File 'lib/roebe/base/colours.rb', line 484

def mediumseagreen(
    i            = '',
    use_colours = use_colours?
  )
  return COLOURS.mediumseagreen(i) if use_colours
  return i
end

#mediumslateblue(i = '', use_colours = use_colours? ) ⇒ Object

#

mediumslateblue

#


663
664
665
666
667
668
669
# File 'lib/roebe/base/colours.rb', line 663

def mediumslateblue(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.mediumslateblue(i) if use_colours
  return i
end

#mediumspringgreen(i = '', use_colours = use_colours? ) ⇒ Object

#

mediumspringgreen

#


561
562
563
564
565
566
567
# File 'lib/roebe/base/colours.rb', line 561

def mediumspringgreen(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.mediumspringgreen(i) if use_colours
  return i
end

#mediumturquoise(i = '', use_colours = use_colours?) ) ⇒ Object

#

mediumturquoise

#


150
151
152
153
# File 'lib/roebe/base/colours.rb', line 150

def mediumturquoise(i = '', use_colours = use_colours?)
  return COLOURS.mediumturquoise(i) if use_colours
  return i
end

#mkdir_p(i, &block) ⇒ Object Also known as: mkdir

#

mkdir_p (mkdir tag)

#


352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/roebe/base/prototype.rb', line 352

def mkdir_p(
    i, &block
  )
  unless File.exist? i
    # ===================================================================== #
    # === Handle blocks next
    # ===================================================================== #
    if block_given?
      yielded = yield
      case yielded
      # =================================================================== #
      # === :be_verbose
      # =================================================================== #
      when :be_verbose
        e "Creating the directory #{sdir(i)} next."
      end
    end
    FileUtils.mkdir_p(i)
  end
end

#mv(old, new = nil, be_verbose_when_moving_existing_files = false, &block) ⇒ Object Also known as: rename_this_file, rename_files, rename_file, rename, move_file, move

#

mv (mv tag)

The first input argument is denoting the old file.

The second input argument is the new name of that old file.

#


216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/roebe/base/prototype.rb', line 216

def mv(
    old,
    new                                   = nil,
    be_verbose_when_moving_existing_files = false,
    &block
  )
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_verbose
    # ===================================================================== #
    when :be_verbose
      be_verbose_when_moving_existing_files = true
    end  
  end
  case be_verbose_when_moving_existing_files
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  when :be_verbose
    be_verbose_when_moving_existing_files = true
  end
  # ======================================================================= #
  # === Handle hashes next:
  # ======================================================================= #
  if old.is_a? Hash
    if old.has_key? :new_name
      new = old.delete(:new_name)
    end
    if old.is_a?(Hash) and old.has_key? :old_name
      old = old.delete(:old_name)
    end
  end
  if File.exist? old
    if be_verbose_when_moving_existing_files
      e "Now renaming from `#{sfile(old)}` to `#{sfile(new)}`."
    end
    FileUtils.mv(old, new)
  else
    e "No file called #{sfile(old)} appears to exist."
  end
end

#n_days_in_this_month(i) ⇒ Object

#

n_days_in_this_month

This method will return how many days are in a given month.

The method will currently not handle leap years though. Thus, february is a failed month.

#


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/roebe/base/time.rb', line 93

def n_days_in_this_month(i)
  case i.to_i
  when 1
    31
  when 2
    28
  when 3
    31
  when 4
    30
  when 5
    31
  when 6
    30
  when 7
    31
  when 8
    31
  when 9
    30
  when 10
    31
  when 11
    30
  when 12
    31
  end
end

#n_pages_in_this_pdf_file?(i) ⇒ Boolean

#

n_pages_in_this_pdf_file?

#

Returns:

  • (Boolean)


387
388
389
390
391
392
# File 'lib/roebe/base/misc.rb', line 387

def n_pages_in_this_pdf_file?(i)
  begin
    require 'pdf_paradise/utility_scripts/pdf_file_n_total_pages.rb'
  rescue LoadError; end
  ::PdfParadise.n_pages_in_this_pdf_file?(i)
end

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)


335
336
337
# File 'lib/roebe/base/misc.rb', line 335

def namespace?
  @namespace
end

#no_file_exists_at(i) ⇒ Object Also known as: no_file_at

#

no_file_exists_at

#


217
218
219
# File 'lib/roebe/base/misc.rb', line 217

def no_file_exists_at(i)
  e "#{rev}No file exists at `#{sfile(i)}`."
end

#olivedrab(i = '', use_colours = use_colours?) ) ⇒ Object

#

olivedrab

#


206
207
208
209
# File 'lib/roebe/base/colours.rb', line 206

def olivedrab(i = '', use_colours = use_colours?)
  return COLOURS.olivedrab(i) if use_colours
  i
end

#open_in_browser(this_URL, &block) ⇒ Object

#

open_in_browser

#


421
422
423
424
425
426
# File 'lib/roebe/base/misc.rb', line 421

def open_in_browser(
    this_URL, &block
  )
  require 'open' unless Object.const_defined?(:Open)
  Open.in_browser(this_URL, &block)
end

#opne(i = '') ⇒ Object

#

opne

#


51
52
53
# File 'lib/roebe/base/opnn.rb', line 51

def opne(i = '')
  opnn; e i
end

#opnesystem(i = '') ⇒ Object

#

opnesystem

#


58
59
60
61
62
63
# File 'lib/roebe/base/opnn.rb', line 58

def opnesystem(
    i = ''
  )
  opne(i)
  system(i)
end

#opnn(i = namespace?, , optional_extra_mode = nil, &block) ⇒ Object

#

opnn

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/roebe/base/opnn.rb', line 14

def opnn(
    i                   = namespace?,
    optional_extra_mode = nil,
    &block
  )
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    i = namespace?
  end
  i = { namespace: i } if i.is_a? String
  if i.is_a? Hash
    i.update(use_colours: use_colours?)
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :no_trailing
    # ===================================================================== #
    when :no_trailing
      i.update(trailing_token: false)
    end
  end
  if Object.const_defined? :Opn
    Opn.opn(i) { optional_extra_mode }
  end
end

#orange(i = '', use_colours = @use_colours) ⇒ Object

#

orange

#


97
98
99
100
101
102
103
# File 'lib/roebe/base/colours.rb', line 97

def orange(
    i           = '',
    use_colours = @use_colours
  )
  return COLOURS.orange(i) if use_colours
  return i
end

#orchid(i = '', use_colours = use_colours? ) ⇒ Object

#

orchid

#


517
518
519
520
521
522
523
# File 'lib/roebe/base/colours.rb', line 517

def orchid(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.orchid(i) if use_colours
  return i
end

#palegoldenrod(i = '', use_colours = use_colours?) ) ⇒ Object

#

palegoldenrod

#


222
223
224
225
# File 'lib/roebe/base/colours.rb', line 222

def palegoldenrod(i = '', use_colours = use_colours?)
  return COLOURS.palegoldenrod(i) if use_colours
  i
end

#palevioletred(i = '', use_colours = use_colours?) ) ⇒ Object

#

palevioletred

#


278
279
280
281
# File 'lib/roebe/base/colours.rb', line 278

def palevioletred(i = '', use_colours = use_colours?)
  return COLOURS.palevioletred(i) if use_colours
  return i
end

#pink(i = '', use_colours = use_colours? ) ⇒ Object

#

pink

#


462
463
464
465
466
467
468
# File 'lib/roebe/base/colours.rb', line 462

def pink(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.pink(i) if use_colours
  return i
end

#powderblue(i = '', use_colours = use_colours? ) ⇒ Object

#

powderblue

#


75
76
77
78
79
80
81
# File 'lib/roebe/base/colours.rb', line 75

def powderblue(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.powderblue(i) if use_colours
  return i
end

#programs_dir?Boolean

#

programs_dir?

This method will only work (and is useful) for RBT-specific support.

#

Returns:

  • (Boolean)


139
140
141
142
143
144
# File 'lib/roebe/base/misc.rb', line 139

def programs_dir?
  unless Object.const_defined?(:RBT) and RBT.respond_to?(:programs_dir?)
    require 'rbt/toplevel_methods/files_and_directories_related_methods.rb'
    RBT.programs_dir?
  end
end

#project_base_dir?Boolean Also known as: project_base_directory?

#

project_base_dir?

#

Returns:

  • (Boolean)


352
353
354
# File 'lib/roebe/base/misc.rb', line 352

def project_base_dir?
  ::Roebe.project_base_dir?
end

#random_html_colourObject

#

random_html_colour

#


400
401
402
# File 'lib/roebe/base/colours.rb', line 400

def random_html_colour
  Colours.random_html_colour
end

#rds(i) ⇒ Object

#

rds

#


108
109
110
111
112
113
114
# File 'lib/roebe/base/prototype.rb', line 108

def rds(i)
  if i.is_a? Array
    i.map {|entry| rds(entry) }
  else
    i.squeeze('/')
  end
end

#read_file_in_iso_encoding(this_file) ⇒ Object

#

read_file_in_iso_encoding

This method will read in a file in the ISO encoding.

You have to check whether the file exists on your own, prior to calling this method.

#


446
447
448
449
450
# File 'lib/roebe/base/prototype.rb', line 446

def read_file_in_iso_encoding(
    this_file
  )
  File.read(this_file, encoding: 'iso8859-1')
end

#read_file_via_the_default_encoding(i, use_this_encoding = main_encoding? ) ⇒ Object Also known as: readlines_via_proper_encoding, file_read_with_proper_encoding, read_this_file, default_read, default_read_file, default_readfile, file_read, read_file, readfile

#

read_file_via_the_default_encoding

This method should be preferentially used whenever file content is to be read in.

#


458
459
460
461
462
# File 'lib/roebe/base/prototype.rb', line 458

def read_file_via_the_default_encoding(
    i, use_this_encoding = main_encoding?
  )
  File.read(i, encoding: use_this_encoding)
end

#read_lines_via_iso_encoding(i) ⇒ Object

#

read_lines_via_iso_encoding

This method will always use ISO encoding, as per its name suggested.

#


185
186
187
# File 'lib/roebe/base/prototype.rb', line 185

def read_lines_via_iso_encoding(i)
  File.readlines(i, encoding: ENCODING_ISO)
end

#readlines_with_main_encoding(this_file) ⇒ Object Also known as: default_readlines, readlines_with_proper_encoding, readlines_with_default_encoding, readlines_with_the_proper_encoding, proper_readlines

#

readlines_with_main_encoding

#


339
340
341
342
343
# File 'lib/roebe/base/prototype.rb', line 339

def readlines_with_main_encoding(
    this_file
  )
  File.readlines(this_file, encoding: main_encoding?)
end

#red(i = '', use_colours = use_colours?) ) ⇒ Object

#

red

#


262
263
264
265
# File 'lib/roebe/base/colours.rb', line 262

def red(i = '', use_colours = use_colours?)
  return COLOURS.red(i) if use_colours
  i
end

#register_sigint(use_this_as_exit_code = 0) ⇒ Object

#

register_sigint

#


96
97
98
99
100
101
102
103
# File 'lib/roebe/base/prototype.rb', line 96

def register_sigint(
    use_this_as_exit_code = 0
  )
  Roebe.register_sigint {{
    use_this_as_exit_code: use_this_as_exit_code,
    invoke_this_method:    :exit
  }}
end

#remove(i) ⇒ Object

#

remove (remove tag)

#


119
120
121
122
123
124
125
# File 'lib/roebe/base/prototype.rb', line 119

def remove(i)
  if File.file? i
    remove_file(i)
  else # Assume directory.
    remove_directory(i)
  end
end

#remove_directory(this_directory) ⇒ Object

#

remove_directory

Use this method if you wish to remove a directory. We will never remove the directory ‘/’ though.

#


58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/roebe/base/prototype.rb', line 58

def remove_directory(
    this_directory
  )
  if this_directory.frozen?
    this_directory = this_directory.dup
  end
  this_directory.squeeze!('/')
  # ======================================================================= #
  # Never get rid of the '/' directory.
  # ======================================================================= #
  unless this_directory == '/'
    FileUtils.rm_rf(this_directory)
  end
end

#remove_file(i, optional_be_verbose = false) ⇒ Object Also known as: delete, delete_file, delete_this_file, remove_this_file, remove_files

#

remove_file (remove tag)

Use this method if you wish to delete a (local) file.

#


146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/roebe/base/prototype.rb', line 146

def remove_file(
    i,
    optional_be_verbose = false
  )
  if i.is_a? Array
    i.each {|entry| remove_file(entry, optional_be_verbose) }
  else
    case optional_be_verbose
    # ===================================================================== #
    # === :be_verbose
    # ===================================================================== #
    when :be_verbose
      optional_be_verbose = true
    end
    if File.exist? i
      if optional_be_verbose
        e "Removing the file `#{sfile(i)}`."
      end
      File.delete(i)
    end
  end
end

#rename_kde_konsole_tab(new_title = '', be_verbose = true) ⇒ Object Also known as: rename_konsole_tab

#

rename_kde_konsole_tab

#


192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/roebe/base/misc.rb', line 192

def rename_kde_konsole_tab(
    new_title  = '',
    be_verbose = true
  )
  case be_verbose
  # ======================================================================= #
  # === :be_quiet
  # ======================================================================= #
  when :be_quiet,
       :be_silent
    be_verbose = false
  end
  ::Roebe.rename_konsole(new_title, be_verbose)
end

#replace_localhost_with_data(i) ⇒ Object

#

replace_localhost_with_data

This method may replace a String such as “localhost/data/SCIENCE/STRATEGEME.cgi” into the variant without “localhost”, such as “/home/x/data/SCIENCE/STRATEGEME.cgi”.

#


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/roebe/base/misc.rb', line 163

def replace_localhost_with_data(i)
  i = i.to_s.dup
  i.sub!(/^http:\/\//,'') if i.start_with? 'http:'
  my_data = ENV['MY_DATA'].to_s.dup
  programming = '/home/x/programming/'
  if i.include?('/data') and my_data.end_with?('data')
    my_data.sub!(/\/data$/, '')
  end
  # ======================================================================= #
  # Input can be like this:
  #
  #   localhost/studium/INDIVIDUELLE_STUDIEN/INDIVIDUELLE_STUDIEN.cgi
  #
  # ======================================================================= #
  if i.include? 'localhost'
    if i.start_with? 'localhost/studium/'
      i.sub!(/^localhost\/studium\//, "#{HOME_DIRECTORY_OF_USER_X}studium/")
    elsif i.include? 'localhost/programming'
      i.gsub!(/localhost\/programming/, programming)
    else
      i.gsub!(/localhost/, my_data)
    end
  end
  return i
end

#report_pwdObject Also known as: show_pwd

#

report_pwd

#


482
483
484
# File 'lib/roebe/base/prototype.rb', line 482

def report_pwd
  e sdir(return_pwd)
end

#require_rescue(i = 'wget_wrapper') ⇒ Object

#

require_rescue

#


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

def require_rescue(
    i = 'wget_wrapper'
  )
  begin
    require 'i'
  rescue LoadError; end
end

#resetObject

#

reset (reset tag)

#


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/roebe/base/reset.rb', line 26

def reset
  # ======================================================================= #
  # === @internal_hash
  #
  # Added this variable in September 2022.
  # ======================================================================= # 
  @internal_hash = {}
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @be_verbose
  # ======================================================================= #
  @be_verbose = true
  # ======================================================================= #
  # === @use_colours
  # ======================================================================= #
  @use_colours = ::Roebe.use_colours?
  # ======================================================================= #
  # === @commandline_arguments
  #
  # Always initialize the commandline arguments to an empty Array here.
  # ======================================================================= #
  @commandline_arguments = []
end

#reset_the_internal_hashObject Also known as: initialize_the_internal_hash

#

reset_the_internal_hash

#


16
17
18
19
20
21
# File 'lib/roebe/base/reset.rb', line 16

def reset_the_internal_hash
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
end

#return_all_directories_from_this_directory(i = return_pwd) ⇒ Object Also known as: return_all_directories, get_all_directories

#

return_all_directories_from_this_directory

This method will return all (sub)directories from the given input directory at hand.

Pass a directory into this method, such as ‘/tmp/’.

#


197
198
199
200
201
202
203
204
205
206
# File 'lib/roebe/base/prototype.rb', line 197

def return_all_directories_from_this_directory(
    i = return_pwd
  )
  target = rds("#{i}/")
  Dir["#{target}*"].select {|entry|
    File.directory?(entry)
  }.flatten.map {|line|
    rds("#{line}/")
  }
end

#return_all_files_from_this_directory(i = return_pwd) ⇒ Object Also known as: obtain_all_files, get_all_files, return_all_files, return_files

#

return_all_files_from_this_directory

This method can be used to obtain all files from the given (input) directory at hand.

#


404
405
406
407
408
409
410
411
# File 'lib/roebe/base/prototype.rb', line 404

def return_all_files_from_this_directory(
    i = return_pwd
  )
  target = rds("#{i}/")
  Dir["#{target}*"].select {|entry|
    File.file?(entry)
  }.flatten
end

#return_current_directoryObject Also known as: return_pwd, get_pwd

#

return_current_directory

#


489
490
491
# File 'lib/roebe/base/prototype.rb', line 489

def return_current_directory
  rds("#{Dir.pwd}/")
end

#return_dd_mm_yyyy(i = ::Time.now) ⇒ Object Also known as: dd_mm_yyyy, today?, return_date

#

return_dd_mm_yyyy

This helper method will return something like:

"03.06.2020"

In other words:

dd.mm.yyyy
#


160
161
162
# File 'lib/roebe/base/time.rb', line 160

def return_dd_mm_yyyy(i = ::Time.now)
  i.strftime '%d.%m.%Y' # => "20.12.2017"
end

#return_file_or_directory_of(i) ⇒ Object

#

return_file_or_directory_of

#


83
84
85
86
87
88
89
90
91
# File 'lib/roebe/base/prototype.rb', line 83

def return_file_or_directory_of(i)
  _ = ''.dup
  ftype = File.ftype(i)
  case ftype
  when 'directory','file'
    _ << ftype.dup
  end
  return _
end

#return_files_from_pwdObject

#

return_files_from_pwd

#


268
269
270
# File 'lib/roebe/base/prototype.rb', line 268

def return_files_from_pwd
  get_files_from(return_pwd)
end

#return_last_part_of_the_current_directoryObject

#

return_last_part_of_the_current_directory

#


76
77
78
# File 'lib/roebe/base/prototype.rb', line 76

def return_last_part_of_the_current_directory
  File.basename(return_current_directory)
end

#return_utcObject

#

return_utc

This method will return a Time object that is in UTC format, such as “2018-12-28 14:09:26 UTC”.

#


72
73
74
# File 'lib/roebe/base/time.rb', line 72

def return_utc
  ::Time.now.getutc
end

#rev(use_colours = use_colours? ) ⇒ Object

#

rev (rev tag)

#


38
39
40
41
42
# File 'lib/roebe/base/colours.rb', line 38

def rev(
    use_colours = use_colours?
  )
  return ::Colours.rev
end

#right_arrow?Boolean Also known as: rarrow?

#

right_arrow?

#

Returns:

  • (Boolean)


210
211
212
# File 'lib/roebe/base/misc.rb', line 210

def right_arrow?
  ''
end

#right_colour(i) ⇒ Object

#

right_colour

#


337
338
339
# File 'lib/roebe/base/colours.rb', line 337

def right_colour(i)
  lightseagreen(i)
end

#roebe_log_directory?Boolean

#

roebe_log_directory?

This method will make sure that there is a trailing ‘roebe/’ part of the log directory.

#

Returns:

  • (Boolean)


409
410
411
412
413
414
415
416
# File 'lib/roebe/base/misc.rb', line 409

def roebe_log_directory?
  _ = log_directory?
  unless _.end_with? 'roebe/'
    _ = _.dup if _.frozen?
    _ << 'roebe/'
  end
  return _
end

#rosybrown(i = '', use_colours = use_colours?) ) ⇒ Object

#

rosybrown

#


134
135
136
137
# File 'lib/roebe/base/colours.rb', line 134

def rosybrown(i = '', use_colours = use_colours?)
  return COLOURS.rosybrown(i) if use_colours
  return i
end

#royalblue(i = '', use_colours = use_colours? ) ⇒ Object

#

royalblue

#


86
87
88
89
90
91
92
# File 'lib/roebe/base/colours.rb', line 86

def royalblue(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.royalblue(i) if use_colours
  return i
end

#ruby_base_directory?Boolean

#

ruby_base_directory?

#

Returns:

  • (Boolean)


78
79
80
# File 'lib/roebe/base/misc.rb', line 78

def ruby_base_directory?
  return File.absolute_path("#{__dir__}/../..")+'/'
end

#runObject

#

run

#


14
15
# File 'lib/roebe/base/run.rb', line 14

def run
end

#run_in_background(i) ⇒ Object

#

run_in_background

#


109
110
111
# File 'lib/roebe/base/misc.rb', line 109

def run_in_background(i)
  esystem "#{i} &"
end

#run_rcfiles_then_run_ata_via_qdbusObject

#

run_rcfiles_then_run_ata_via_qdbus

#


49
50
51
52
53
54
55
# File 'lib/roebe/base/misc.rb', line 49

def run_rcfiles_then_run_ata_via_qdbus
  require 'rcfiles'
  Rcfiles.run
  esystem 'qdbus org.kde.konsole-`pidof -s konsole` /Sessions/2 runCommand "ata"'
  esystem 'qdbus org.kde.konsole-`pidof -s konsole` /Sessions/3 runCommand "ata"'
  esystem 'qdbus org.kde.konsole-`pidof -s konsole` /Sessions/4 runCommand "ata"'
end

#sandybrown(i = '', use_colours = use_colours? ) ⇒ Object

#

sandybrown

#


440
441
442
443
444
445
446
# File 'lib/roebe/base/colours.rb', line 440

def sandybrown(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.sandybrown(i) if use_colours
  return i
end

#sdir(i = '') ⇒ Object

#

sdir

#


297
298
299
# File 'lib/roebe/base/colours.rb', line 297

def sdir(i = '')
  ::Roebe.sdir(i)
end

#seagreen(i = '', use_colours = use_colours? ) ⇒ Object

#

seagreen

#


652
653
654
655
656
657
658
# File 'lib/roebe/base/colours.rb', line 652

def seagreen(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.seagreen(i) if use_colours
  return i
end

#set_be_verbose(i = true) ⇒ Object Also known as: be_verbose, yes_be_verbose

#

set_be_verbose

#


497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/roebe/base/prototype.rb', line 497

def set_be_verbose(
    i = true
  )
  case i
  # ======================================================================= #
  # === :be_silent
  # ======================================================================= #
  when :be_silent,
       :be_quiet
    i = false
  end
  @be_verbose = i
end

#set_xorg_buffer(i) ⇒ Object

#

set_xorg_buffer

#


224
225
226
227
# File 'lib/roebe/base/misc.rb', line 224

def set_xorg_buffer(i)
  require 'roebe/toplevel_methods/xorg_buffer.rb'
  XorgBuffer[i] if Object.const_defined? :XorgBuffer
end

#sfancy(i = '', use_colours = @use_colours) ⇒ Object

#

sfancy

#


386
387
388
389
390
391
392
393
394
395
# File 'lib/roebe/base/colours.rb', line 386

def sfancy(
    i           = '',
    use_colours = @use_colours
  )
  if use_colours
    ::Roebe.sfancy(i)
  else
    return i
  end
end

#sfile(i = '', use_colours = use_colours?) ) ⇒ Object

#

sfile

#


286
287
288
289
290
291
292
# File 'lib/roebe/base/colours.rb', line 286

def sfile(i = '', use_colours = use_colours?)
  if use_colours
    ::Roebe.sfile(i)
  else
    i
  end
end

#show_helpObject

#

show_help (help tag)

The sub-class can overwrite this method.

#


299
300
301
302
303
# File 'lib/roebe/base/misc.rb', line 299

def show_help
  e
  e 'Currently no help options are documented for this class.'
  e
end

#silent_redirection?Boolean

#

silent_redirection?

#

Returns:

  • (Boolean)


117
118
119
# File 'lib/roebe/base/misc.rb', line 117

def silent_redirection?
  ::Roebe.silent_redirection?
end

#simp(i = '') ⇒ Object

#

simp

#


14
15
16
# File 'lib/roebe/base/simp.rb', line 14

def simp(i = '')
  ::Roebe.simp(i)
end

#simple_esystem(i) ⇒ Object

#

simple_esystem

This method only calls two other methods:

1) e()
2) system()

This method is NOT allowed to become more complex than that.

#


21
22
23
24
# File 'lib/roebe/base/esystem.rb', line 21

def simple_esystem(i)
  e "#{rev}i"
  system i
end

#skyblue(i = '', use_colours = use_colours?) ) ⇒ Object

#

skyblue

#


254
255
256
257
# File 'lib/roebe/base/colours.rb', line 254

def skyblue(i = '', use_colours = use_colours?)
  return COLOURS.skyblue(i) if use_colours
  i
end

#slateblue(i = '', use_colours = use_colours? ) ⇒ Object

#

slateblue

#


180
181
182
183
184
185
# File 'lib/roebe/base/colours.rb', line 180

def slateblue(
    i = '', use_colours = use_colours?
  )
  return COLOURS.slateblue(i) if use_colours
  return i
end

#slategray(i = '', use_colours = use_colours?) ) ⇒ Object

#

slategray

#


214
215
216
217
# File 'lib/roebe/base/colours.rb', line 214

def slategray(i = '', use_colours = use_colours?)
  return COLOURS.slategray(i) if use_colours
  i
end

#springgreen(i = '', use_colours = use_colours? ) ⇒ Object

#

springgreen

#


158
159
160
161
162
163
164
# File 'lib/roebe/base/colours.rb', line 158

def springgreen(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.springgreen(i) if use_colours and COLOURS.respond_to?(:springgreen)
  return i
end

#steelblue(i = '', use_colours = use_colours? ) ⇒ Object

#

steelblue

#


506
507
508
509
510
511
512
# File 'lib/roebe/base/colours.rb', line 506

def steelblue(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.steelblue(i) if COLOURS and use_colours and COLOURS.respond_to?(:steelblue)
  return i
end

#swarn(i = '', use_colours = @use_colours) ⇒ Object

#

swarn

#


351
352
353
354
355
356
357
358
359
360
# File 'lib/roebe/base/colours.rb', line 351

def swarn(
    i           = '',
    use_colours = @use_colours
  )
  if use_colours
    return ::Colours.swarn(i)
  else
    return i
  end
end
#

See the core docu at:

https://ruby-doc.org/core/File.html#method-c-symlink
#


37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/roebe/base/symlink.rb', line 37

def symlink(
    old_target,
    new_target
  )
  if File.exist? new_target
    e "The target at #{sfile(new_target)} aready exists."
  else
    begin
      File.symlink(old_target, new_target)
    rescue Errno::EEXIST => error
      pp error
    end
  end
end

#teal(i = '', use_colours = use_colours?) ) ⇒ Object

#

teal

#


230
231
232
233
# File 'lib/roebe/base/colours.rb', line 230

def teal(i = '', use_colours = use_colours?)
  return COLOURS.teal(i) if use_colours
  i
end

#temp_dir?Boolean

#

temp_dir?

This method will return the path to the (local) temporary directory.

#

Returns:

  • (Boolean)


433
434
435
436
437
438
439
440
441
442
443
# File 'lib/roebe/base/misc.rb', line 433

def temp_dir?
  _ = ENV['MY_TEMP_DIR']
  if _.nil? or _.empty?
    if File.directory?('/home/x/Temp')
      _ = '/home/x/Temp'
    elsif File.directory?('/tmp')
      _ = '/tmp'
    end
  end
  return _
end

#to_camelcase(i) ⇒ Object

#

to_camelcase

#


48
49
50
# File 'lib/roebe/base/prototype.rb', line 48

def to_camelcase(i)
  i.split('_').map(&:capitalize).join
end

#to_counted_hash(array) ⇒ Object

#

to_counted_hash

This method expects an Array as its input.

This Array is then converted into a Hash, or rather, a Hash will be returned that keeps track of how many times a specific key was found in that Array.

#


434
435
436
# File 'lib/roebe/base/prototype.rb', line 434

def to_counted_hash(array)
  array.tally
end

#tomato(i = '', use_colours = use_colours?) ) ⇒ Object

#

tomato

#


119
120
121
122
# File 'lib/roebe/base/colours.rb', line 119

def tomato(i = '', use_colours = use_colours?)
  return COLOURS.tomato(i) if use_colours
  return i
end

#touch(i, be_verbose = true) ⇒ Object Also known as: create_file

#

touch (touch tag)

#


376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/roebe/base/prototype.rb', line 376

def touch(
    i,
    be_verbose = true
  )
  i = [i].flatten.compact
  i.each {|this_file|
    unless File.exist? this_file
      if be_verbose
        e "#{rev}Next creating the file `#{sfile(this_file)}`."
      end
      begin # Need to rescue it here.
        FileUtils.touch(this_file)
        if File.exist?(this_file)
          FileUtils.chmod(0644, this_file)
        end
      rescue Exception => error
        pp error
      end
    end
  }
end

#try_to_require_the_beautiful_url_gemObject Also known as: try_to_require_the_beautiful_url_project

#

try_to_require_the_beautiful_url_gem

#


31
32
33
# File 'lib/roebe/base/support_for_beautiful_url.rb', line 31

def try_to_require_the_beautiful_url_gem
  require 'roebe/requires/failsafe_require_of_beautiful_url.rb'
end

#try_to_require_the_html_templateObject

#

try_to_require_the_html_template

#


448
449
450
451
452
# File 'lib/roebe/base/misc.rb', line 448

def try_to_require_the_html_template
  begin
    require 'cyberweb/requires/require_the_html_template.rb'
  rescue LoadError; end
end

#try_to_require_the_open_gemObject

#

try_to_require_the_open_gem

#


368
369
370
371
372
# File 'lib/roebe/base/misc.rb', line 368

def try_to_require_the_open_gem
  begin
    require 'open'
  rescue LoadError; end
end

#try_to_require_the_program_information_gemObject Also known as: try_to_require_program_information

#

try_to_require_the_program_information_gem

#


359
360
361
362
363
# File 'lib/roebe/base/misc.rb', line 359

def try_to_require_the_program_information_gem
  begin
    require 'program_information'
  rescue LoadError; end
end

#try_to_require_the_xorg_bufferObject

#

try_to_require_the_xorg_buffer

#


239
240
241
242
243
# File 'lib/roebe/base/misc.rb', line 239

def try_to_require_the_xorg_buffer
  begin
    require 'xorg_buffer'
  rescue LoadError; end
end

#use_colours?Boolean

#

use_colours?

#

Returns:

  • (Boolean)


47
48
49
# File 'lib/roebe/base/colours.rb', line 47

def use_colours?
  @use_colours
end

#verbose_truth(i) ⇒ Object Also known as: vb, vt, yes_no, yes_or_no

#

verbose_truth

#


15
16
17
# File 'lib/roebe/base/verbose_truth.rb', line 15

def verbose_truth(i)
  return ::Roebe.verbose_truth(i)
end

#weekday?(this_weekday_as_number = Date.today.wday) ⇒ Boolean

#

weekday?

#

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/roebe/base/time.rb', line 60

def weekday?(
    this_weekday_as_number = Date.today.wday
  )
  DAY_NAMES[this_weekday_as_number] # => "Mon"'
end

#word_wrap(text, line_width = 80) ⇒ Object

#

word_wrap

#


377
378
379
380
381
382
# File 'lib/roebe/base/misc.rb', line 377

def word_wrap(
    text,
    line_width = 80
  )
  return text.scan(/\S.{0,#{line_width}}\S(?=\s|$)|\S+/).join(N)
end

#write_what_into(what, into, use_this_mode = 'w+') ⇒ Object Also known as: store_what_into, save_what_into, save_what_to

#

write_what_into

#


16
17
18
19
20
# File 'lib/roebe/base/write_what_into.rb', line 16

def write_what_into(
    what, into, use_this_mode = 'w+'
  )
  Roebe.write_what_into(what, into, use_this_mode)
end

#yellow(i = '', use_colours = use_colours? ) ⇒ Object Also known as: yel

#

yellow

#


495
496
497
498
499
500
501
# File 'lib/roebe/base/colours.rb', line 495

def yellow(
    i           = '',
    use_colours = use_colours?
  )
  return COLOURS.yellow(i) if use_colours
  return i
end