Class: Gtin2atc::Options

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



37
38
39
40
41
42
43
44
# File 'lib/gtin2atc/options.rb', line 37

def initialize
  @parser = OptionParser.new
  @opts   = Options.default_opts
  @parser.on('--log')             {|v| @opts[:log] = true }
  @parser.on('--compare')         {|v| @opts[:compare] = true }
  @parser.on('--full')            {|v| @opts[:full] = true }
  @parser.on_tail('-h', '--help') { puts Options.help; exit }
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/gtin2atc/options.rb', line 7

def opts
  @opts
end

#parserObject (readonly)

Returns the value of attribute parser.



7
8
9
# File 'lib/gtin2atc/options.rb', line 7

def parser
  @parser
end

Class Method Details

.default_optsObject



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

def Options.default_opts
  {
    :log          => false,
    :compare      => false,
    :full         => false,
  }
end

.helpObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gtin2atc/options.rb', line 15

def Options.help
  <<EOS
#$0 ver.#{Gtin2atc::VERSION}
Usage:
  gtin2atc [--compare] [--log] [file_with_gtin or gtin or pharmacode] [output_file]
If file_with_gtin is given only the GTIN (or pharamacode) (one per line) is outputted.
If a second parameter output_file is given the name of the generated csv file.
If no file or gtin is given, alle GTIN will be processed.
If a file oddb_calc.xml (produced via oddb2xml --calc) is found in the current directory,
its content is read to add the daily drug dose and dose information for each article.

--log               log important actions

--compare           download an compare GTIN/ATC_code from BAG, SwissIndex and RefData
                    For each GTIN we will output a message if it can be only found in the
                    * BAG http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip
                    * SwissIndex e-mediat: http://swissindex.e-mediat.net/SwissindexPharma_out_V101
                    * or if the ATC_Code does not not match
-- full             if --compare and --full given produce 15 detailed report files
-h,   --help         Show this help message.
EOS
end