Class: POI::Opt
- Inherits:
-
Object
- Object
- POI::Opt
- Defined in:
- lib/poi/opt.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#optparser ⇒ Object
readonly
Returns the value of attribute optparser.
Instance Method Summary collapse
-
#initialize ⇒ Opt
constructor
A new instance of Opt.
- #parse(argv) ⇒ Object
Constructor Details
#initialize ⇒ Opt
Returns a new instance of Opt.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/poi/opt.rb', line 6 def initialize @options = {} @optparser = OptionParser.new do |opts| opts. = "Usage: poi -f [FILE / URL] [-d]" opts.on('-f', '--file FILE / URL', 'Generate using .poi file.') do |file| @options[:file] = file end opts.on('-d', '--delete', 'Delete all generated file') do @options[:delete] = true end opts.on('-p', '--pack [PACK]', 'Pack .poipack file into .poi') do |pack| @options[:pack] = pack || '.poipack' end opts.on('-t', '--target TARGET', 'Packaging target') do |target| @options[:target] = target end opts.on('-h', '--help', "Print help message") do @options[:help] = true puts opts exit end end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/poi/opt.rb', line 5 def @options end |
#optparser ⇒ Object (readonly)
Returns the value of attribute optparser.
5 6 7 |
# File 'lib/poi/opt.rb', line 5 def optparser @optparser end |
Instance Method Details
#parse(argv) ⇒ Object
36 37 38 |
# File 'lib/poi/opt.rb', line 36 def parse(argv) @optparser.parse!(argv) end |