Module: Lotu::Helpers::Util
Instance Method Summary collapse
- #class_debug_info ⇒ Object
- #instance_debug_info ⇒ Object
-
#parse_cli_options ⇒ Object
As seen in: ruby.about.com/od/advancedruby/a/optionparser.htm.
Instance Method Details
#class_debug_info ⇒ Object
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.}\n" if self.class.respond_to? :behavior_options end end |
#instance_debug_info ⇒ Object
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_options ⇒ Object
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 # This hash will hold all of the options # parsed from the command-line by # OptionParser. = {} optparse = OptionParser.new do|opts| # Set a banner, displayed at the top # of the help screen. opts. = "Usage: #{$0} [options]" # Define the options, and what they do [:debug] = false opts.on( '-d', '--debug', 'Output debug info' ) do [:debug] = true end [:fullscreen] = false opts.on( '-f', '--fullscreen', 'Runs the game in fullscreen mode' ) do [: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 [:debug] puts "Running in fullscreen mode".red if [:fullscreen] end |