Module: GamesAndRpgParadise::Base::ExtensionsForAGamebook

Overview

:GamesAndRpgParadise::Base::ExtensionsForAGamebook

Constant Summary collapse

DIRECTORY_FOR_THE_GAMEBOOKS =
#

DIRECTORY_FOR_THE_GAMEBOOKS

#
::GamesAndRpgParadise.directory_to_the_gamebooks?

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GamesAndRpgParadise::Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Class Method Details

.use_gtk?Boolean

#

:GamesAndRpgParadise::BaseExtensions.use_gtk?

#

Returns:

  • (Boolean)


90
91
92
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 90

def self.use_gtk?
  Object.const_defined?(:Gtk)
end

Instance Method Details

#available_gamebooks?Boolean

#

available_gamebooks?

#

Returns:

  • (Boolean)


51
52
53
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 51

def available_gamebooks?
  ::GamesAndRpgParadise.available_gamebooks?
end

#io_download(remote_URL, path = :infer_automatically) ⇒ Object

#

io_download

IO.copy_stream copies src to dst.

The first argument should be the remote URL to be used.

Usage example:

io_download('https://www.projectaon.org/en/xhtml/lw/01fftd/sect20.htm')
#


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 67

def io_download(
    remote_URL,
    path = :infer_automatically
  )
  case path
  # ======================================================================= #
  # === :infer_automatically
  # ======================================================================= #
  when :infer_automatically,
       :default
    path = File.basename(remote_URL)
  end
  remote_URL = URI.open(remote_URL)
  ::IO.copy_stream(
    remote_URL,
    path
  )
  return File.absolute_path(path)
end

#roll_this_die(i = '2W6') ⇒ Object

#

roll_this_die

This will simply return the value (the result), without reporting the result to the user. That way downstream code has to do the reporting part on its own.

#


109
110
111
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 109

def roll_this_die(i = '2W6')
  return ::GamesAndRpgParadise.silently_roll_this_die(i)
end

#use_gtk?Boolean

#

use_gtk?

#

Returns:

  • (Boolean)


97
98
99
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 97

def use_gtk?
  Object.const_defined?(:Gtk)
end

#wget(remote_URL) ⇒ Object

#

wget

#


35
36
37
38
39
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 35

def wget(remote_URL)
  cmd = "wget #{remote_URL}"
  e cmd
  system cmd
end

#yaml_gamebooks_dir?Boolean

#

yaml_gamebooks_dir?

#

Returns:

  • (Boolean)


44
45
46
# File 'lib/games_and_rpg_paradise/base/extensions/extensions_for_a_gamebook.rb', line 44

def yaml_gamebooks_dir?
  "#{::GamesAndRpgParadise.project_base_directory?}yaml/gamebooks/"
end