Module: Lotu::Helpers::Util

Included in:
Actor, Game
Defined in:
lib/lotu/helpers/util.rb

Instance Method Summary collapse

Instance Method Details

#class_debug_infoObject



7
8
9
10
11
# File 'lib/lotu/helpers/util.rb', line 7

def class_debug_info
  if $lotu.debug
    puts "[#{self.class.to_s.green}] Behavior options: #{self.class.behavior_options}\n" if self.class.respond_to? :behavior_options
  end
end

#instance_debug_infoObject



13
14
15
16
17
# File 'lib/lotu/helpers/util.rb', line 13

def instance_debug_info
  if $lotu.debug
    puts "[#{self.class.to_s.yellow}] Systems: #{systems.keys}\n" if systems
  end
end

#parse_cli_optionsObject



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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/lotu/helpers/util.rb', line 20

def parse_cli_options
  # This hash will hold all of the options
  # parsed from the command-line by
  # OptionParser.
  options = {}

  optparse = OptionParser.new do|opts|
    # Set a banner, displayed at the top
    # of the help screen.
    opts.banner = "Usage: #{$0} [options]"
    
    # Define the options, and what they do
    options[:debug] = false
    opts.on( '-d', '--debug', 'Output debug info' ) do
      options[:debug] = true
    end

    options[:fullscreen] = false
    opts.on( '-f', '--fullscreen', 'Runs the game in fullscreen mode' ) do
      options[:fullscreen] = true
    end
    
    # This displays the help screen, all programs are
    # assumed to have this option.
    opts.on( '-h', '--help', 'Display this screen' ) do
      puts opts
      exit
    end
  end

  # Parse the command-line. Remember there are two forms
  # of the parse method. The 'parse' method simply parses
  # ARGV, while the 'parse!' method parses ARGV and removes
  # any options found there, as well as any parameters for
  # the options. What's left is the list of files to resize.
  optparse.parse!

  puts "Showing debug info".red if options[:debug]
  puts "Running in fullscreen mode".red if options[:fullscreen]
  options
end