class AsciiParadise::Base

Public Class Methods

animation_dir?() click to toggle source
#

AsciiParadise::Base.animation_dir?

#
# File lib/ascii_paradise/base/base.rb, line 129
def self.animation_dir?
  ::AsciiParadise.animations_dir?
end
e(i = '') click to toggle source
#

Base.e

#
# File lib/ascii_paradise/base/colours.rb, line 104
def self.e(i = '')
  ::AsciiParadise.e(i)
end
new( optional_arguments = ARGV ) { || ... } click to toggle source
#

initialize

#
# File lib/ascii_paradise/base/initialize.rb, line 14
def initialize(
    optional_arguments = ARGV
  )
  register_sigint
  reset
  # ======================================================================= #
  # === Handle blocks given to us next
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Hash 
      # =================================================================== #
      # === :run_n_times
      # =================================================================== #
      if yielded.has_key? :run_n_times
        set_run_n_times(yielded.delete(:run_n_times))
      end
      # =================================================================== #
      # === main_dir
      # =================================================================== #
      if yielded.has_key? :main_dir
        set_main_dir(yielded.delete(:main_dir))
      # =================================================================== #
      # === :animation_dir
      # =================================================================== #
      elsif yielded.has_key? :animation_dir
        set_main_dir(yielded.delete(:animation_dir))
      end
      # =================================================================== #
      # === :sleep_for_n_seconds
      # =================================================================== #
      if yielded.has_key? :sleep_for_n_seconds
        set_sleep_for_n_seconds(yielded.delete(:sleep_for_n_seconds))
      end
    else # Else assume a Symbol.
      case yielded
      # =================================================================== #
      # Prevent instant running.
      # =================================================================== #
      when :do_not_run_already,
           :do_not_run_yet
        do_not_run_already
      end
    end
  end
end
run() click to toggle source
#

AsciiParadise::Base.run

#
# File lib/ascii_paradise/base/base.rb, line 152
def self.run
  new
end

Public Instance Methods

animation_dir?()
animation_directory?() click to toggle source
#

animation_directory?

#
# File lib/ascii_paradise/base/base.rb, line 136
def animation_directory?
  Base.animation_dir?
end
Also aliased as: animation_dir?, which_dir?, main_dir?
clear_screen() click to toggle source
#

clear_screen

#
# File lib/ascii_paradise/base/base.rb, line 53
def clear_screen
  ::AsciiParadise.clear_screen
end
colour_parse_this_string(i) click to toggle source
#

colour_parse_this_string

#
# File lib/ascii_paradise/base/colours.rb, line 136
def colour_parse_this_string(i)
  ::AsciiParadise.colour_parse_this_string(i)
end
debug?() click to toggle source
#

debug?

#
# File lib/ascii_paradise/base/debug.rb, line 25
def debug?
  ::AsciiParadise.debug?
end
do_not_run_already() click to toggle source
#

do_not_run_already

#
# File lib/ascii_paradise/base/base.rb, line 70
def do_not_run_already
  @run_already = false
end
Also aliased as: do_not_run_yet
do_not_run_yet()
Alias for: do_not_run_already
do_not_use_clear() click to toggle source
#

do_not_use_clear

#
# File lib/ascii_paradise/base/base.rb, line 46
def do_not_use_clear
  @do_clear = false
end
do_use_random_colour() click to toggle source
#

do_use_random_colour

#
# File lib/ascii_paradise/base/colours.rb, line 43
def do_use_random_colour
  set_colour(:random_colour)
end
Also aliased as: use_a_random_colour
do_wait_for_keypress_event(i = true) click to toggle source
#

do_wait_for_keypress_event

The argument can be true, by default, or also another argument. Some symbols may have a special instruction.

#
# File lib/ascii_paradise/base/base.rb, line 63
def do_wait_for_keypress_event(i = true)
  @wait_for_keypress_on_each_frame = i
end
e(i = '') click to toggle source
#

e

#
# File lib/ascii_paradise/base/colours.rb, line 111
def e(i = '')
  Base.e(i)
end
enable_debug() click to toggle source
#

enable_debug

Delegate to the toplevel-method next.

#
# File lib/ascii_paradise/base/debug.rb, line 18
def enable_debug
  ::AsciiParadise.enable_debug
end
help()
Alias for: show_help
is_animated?() click to toggle source
#

is_animated?

By default, sublcasses of this class are not animated. This is different for those ruby files that subclass from AsciiParadise::Animation.

#
# File lib/ascii_paradise/base/base.rb, line 110
def is_animated?
  false
end
main_dir?()
menu(i) click to toggle source
#

menu (menu tag)

#
project_base_dir?() click to toggle source
#

project_base_dir?

#
# File lib/ascii_paradise/base/base.rb, line 84
def project_base_dir?
  ::AsciiParadise.project_base_dir?
end
register_sigint() click to toggle source
#

register_sigint

#
# File lib/ascii_paradise/base/base.rb, line 32
def register_sigint
  ::AsciiParadise.register_sigint
end
remove_trailing_ansci_escape_code(i) click to toggle source
#

remove_trailing_ansci_escape_code

#
# File lib/ascii_paradise/base/colours.rb, line 118
def remove_trailing_ansci_escape_code(i)
  ::Colours.remove_trailing_end_from(i)
end
report_how_many_animated_components_exist() click to toggle source
#

report_how_many_animated_components_exist

#
# File lib/ascii_paradise/base/base.rb, line 98
def report_how_many_animated_components_exist
  e 'There are '+
    sfancy(::AsciiParadise.n_animated_components?.to_s)+
    ' animated entries available.'
end
reset() click to toggle source
#

reset

#
# File lib/ascii_paradise/base/reset.rb, line 14
def reset
  # ======================================================================= #
  # By default we will use colours.
  # ======================================================================= #
  @use_colours = true
  # ======================================================================= #
  # === @wait_for_keypress_on_each_frame
  #
  # Whether to wait for a keypress event, on each frame, or whether
  # we will not. This is mostly only used for debugging purposes.
  #
  # Thus, by default this variable is set to false.
  # ======================================================================= #
  @wait_for_keypress_on_each_frame = false
  # ======================================================================= #
  # === @run_already
  #
  # If true then the animation will be run at once when called.
  # ======================================================================= #
  @run_already = true
end
return_basename_of_this_file_without_the_extension(i) click to toggle source
#

return_basename_of_this_file_without_the_extension

#
# File lib/ascii_paradise/base/base.rb, line 145
def return_basename_of_this_file_without_the_extension(i)
  File.basename(i).sub(/#{File.extname(i)}$/,'')
end
return_random_colour() click to toggle source
#

return_random_colour

This method will return, as String, a random HTML colour, such as “steelblue”.

#
# File lib/ascii_paradise/base/colours.rb, line 53
def return_random_colour
  ::Colours.random_html_colour
end
rev() click to toggle source
#

rev

#
# File lib/ascii_paradise/base/colours.rb, line 125
def rev
  if @use_colours
    ::Colours.rev
  else
    ''
  end
end
royalblue(i = '') click to toggle source
#

royalblue

#
# File lib/ascii_paradise/base/colours.rb, line 170
def royalblue(i = '')
  i = i.dup
  i = ::Colours.send(__method__, i) if @use_colours
  i
end
set_colour( i = ::AsciiParadise.colour? )
Alias for: set_use_this_colour
set_use_this_colour( i = ::AsciiParadise.colour? ) click to toggle source
#

set_use_this_colour

Set a specific colour through this method here.

Setting a random colour is also possible, e. g. by using as argument :random_colour.

#
# File lib/ascii_paradise/base/colours.rb, line 22
def set_use_this_colour(
    i = ::AsciiParadise.colour?
  )
  case i
  when nil, :default
    i = DEFAULT_COLOUR_TO_USE # Hardcoded default in this case.
  end
  i = i.to_s.dup # Do not retain the String as frozen.
  i.delete!('-') if i.include? '--'
  case i # case tag
  when /^-?-?random(_|-)?colour$/i # handofgod --colour=random-colour
    i = return_random_colour
  end
  i = i.to_sym unless i.is_a? Symbol
  @use_this_colour = i
end
Also aliased as: set_colour, use_this_colour
sfancy(i) click to toggle source
#

sfancy

#
# File lib/ascii_paradise/base/colours.rb, line 71
def sfancy(i)
  if @use_colours
    AsciiParadise.sfancy(i)
  else
    ''
  end
end
sfile(i) click to toggle source
#

sfile

#
# File lib/ascii_paradise/base/colours.rb, line 82
def sfile(i)
  if @use_colours
    AsciiParadise.sfile(i)
  else
    ''
  end
end
show_available_components() click to toggle source
#

show_available_components

#
# File lib/ascii_paradise/base/base.rb, line 91
def show_available_components
  ::AsciiParadise.show_available_ascii_components
end
show_help() click to toggle source
#

show_help (help tag)

To invoke this method, try:

fireworks --help
#
# File lib/ascii_paradise/base/base.rb, line 122
def show_help
  ::AsciiParadise.show_help
end
Also aliased as: help
simp(i) click to toggle source
#

simp

#
# File lib/ascii_paradise/base/colours.rb, line 60
def simp(i)
  if @use_colours
    AsciiParadise.simp(i)
  else
    ''
  end
end
slategrey(i = '') click to toggle source
#

slategrey

#
# File lib/ascii_paradise/base/colours.rb, line 161
def slategrey(i = '')
  i = i.dup
  i = ::Colours.send(__method__, i) if @use_colours
  i
end
sort_files(i) click to toggle source
#

sort_files

#
# File lib/ascii_paradise/base/base.rb, line 39
def sort_files(i)
  ::AsciiParadise.sort_files(i)
end
static_dir?() click to toggle source
#

static_dir?

#
# File lib/ascii_paradise/base/base.rb, line 77
def static_dir?
  "#{project_base_dir?}static_ascii/"
end
steelblue(i = '') click to toggle source
#

steelblue

#
# File lib/ascii_paradise/base/colours.rb, line 143
def steelblue(i = '')
  i = i.dup
  i = ::Colours.send(__method__, i) if @use_colours
  i
end
Also aliased as: tomato
swarn(i) click to toggle source
#

swarn

#
# File lib/ascii_paradise/base/colours.rb, line 93
def swarn(i)
  if @use_colours
    AsciiParadise.swarn(i)
  else
    ''
  end
end
tomato(i = '')
Alias for: steelblue
use_a_random_colour()
use_this_colour( i = ::AsciiParadise.colour? )
Alias for: set_use_this_colour
which_dir?()