Class: Rumld::OptionsStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/rumld/options_struct.rb

Instance Method Summary collapse

Constructor Details

#initializeOptionsStruct

Returns a new instance of OptionsStruct.



8
9
10
11
12
13
14
# File 'lib/rumld/options_struct.rb', line 8

def initialize
  default_options = { :doc_dir => './doc',
    :files => RUMLD_DEFAULT_FILES,
    :outfile => './ruml.dot',
  :source_dirs => ['./lib', './app/models'] }
  super(default_options)
end

Instance Method Details

#parse(args) ⇒ Object



16
17
18
19
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
# File 'lib/rumld/options_struct.rb', line 16

def parse(args)
  @opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: rumld [options]"
    opts.separator ""
    opts.separator "Options:"
    opts.on("-d", "--doc_dir ./ruml_doc", "Directory to generate rumld's", "working RDoc") do |value|
      self.doc_dir = value
    end

    opts.on("-o", "--outfile ruml.dot", "Output file") do |value|
      self.outfile = value
    end

    opts.on("-s", "--source_dirs lib,app/models", Array, "Directories for files") do |value|
      self.source_dirs = value
    end
    opts.on("-f", "--files file1[,fileN]", Array, "Files to graph", "defaults to #{RUMLD_DEFAULT_FILES.join(',')}") do |value|
      self.files = value
    end

  end

  begin
    @opt_parser.parse!(args)
  rescue OptionParser::AmbiguousOption
    option_error "Ambiguous option"
  rescue OptionParser::InvalidOption
    option_error "Invalid option"
  rescue OptionParser::InvalidArgument
    option_error "Invalid argument"
  rescue OptionParser::MissingArgument
    option_error "Missing argument"
  end
end