Class: Urltest::Commands::Options
- Inherits:
-
Object
- Object
- Urltest::Commands::Options
- Defined in:
- lib/urltest/commands/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #parse ⇒ Object
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
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 35 36 37 38 39 |
# File 'lib/urltest/commands/options.rb', line 9 def initialize(args) @options = OpenStruct.new @options.times = 10 opts = OptionParser.new do |opts| opts. = "\nSpeed test for your url(api)\n\nUsage: urltest [options]" opts.version = Urltest::VERSION opts.separator '' opts.separator 'Optional:' opts.on_head('-t', '--times [N]', Integer, 'Request times') do |t| @options.times = t || 10 end opts.on_head('-l', '--link [URL]', String, 'URL link') do |l| @options.link = l end opts.on('--version', "Show version") do |v| puts opts.version exit end opts.on('--help', "Show help") do |v| puts opts exit end end opts.parse!(args) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/urltest/commands/options.rb', line 7 def @options end |
Instance Method Details
#parse ⇒ Object
41 42 43 |
# File 'lib/urltest/commands/options.rb', line 41 def parse @options end |