Class: GBRb::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/gbrb/options.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gbrb/options.rb', line 5

def initialize argv
  if argv.length < 1
    STDERR.puts "No game cartridge specified. See `gbrb -h` for usage."
    exit 1
  end

  @config = { skip_boot:      false,
              debug:          false,
              cartridge_path: argv.pop
  }

  if @config[:cartridge_path] =~ /^-/
    argv.push @config[:cartridge_path]
    @config[:cartridge_path] = ''
  end

  parse argv
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &b) ⇒ Object



24
25
26
# File 'lib/gbrb/options.rb', line 24

def method_missing m, *a, &b
  @config.fetch(m) { super }
end