Class: Vedeu::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = []) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
# File 'lib/vedeu/configuration.rb', line 9

def initialize(args = [])
  @args    = args
  @options = {}
end

Class Method Details

.configure(args = []) ⇒ Object



5
6
7
# File 'lib/vedeu/configuration.rb', line 5

def self.configure(args = [])
  new(args).configure
end

Instance Method Details

#configureObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vedeu/configuration.rb', line 14

def configure
  parser = OptionParser.new do |opts|
    opts.banner = "Usage: #{$PROGRAM_NAME} [options]"

    opts.on('-1', '--run-once', 'Run application once.') do
      @options[:interactive] = false
    end

    opts.on('-c', '--cooked', 'Run application in cooked mode.') do
      @options[:mode] = :cooked
    end

    opts.on('-r', '--raw', 'Run application in raw mode (default).') do
      @options[:mode] = :raw
    end
  end
  parser.parse!(args)

  options
end