Class: CLIOpts
- Inherits:
-
Object
- Object
- CLIOpts
- Defined in:
- lib/yahoofinance.rb
Class Method Summary collapse
- .help(options, opts) ⇒ Object
-
.parse(args, options) ⇒ Object
Return a structure describing the options.
Class Method Details
.help(options, opts) ⇒ Object
524 525 526 527 528 |
# File 'lib/yahoofinance.rb', line 524 def self.help( , opts ) puts "ERROR: #{.helpMsg}" if .helpMsg puts opts exit end |
.parse(args, options) ⇒ Object
Return a structure describing the options.
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/yahoofinance.rb', line 531 def self.parse( args, ) opts = OptionParser.new do |opts| opts. = "Usage: yahoofinance.rb [options] <symbol>" opts.separator "" opts.on( "-s", "Retrieve standard quotes (default)." ) { .quote_class = YahooFinance::StandardQuote } opts.on( "-x", "Retrieve extended quotes." ) { .quote_class = YahooFinance::ExtendedQuote } opts.on( "-r", "Retrieve real-time quotes." ) { .quote_class = YahooFinance::RealTimeQuote } opts.on( '-z', "Retrieve historical quotes." ) { .quote_class = nil } opts.on( "-d", "--days N", Integer, "Number of days of historical " + "quotes to retrieve. Default is 90." ) { |days| .historical_days = days } opts.on( "-h", "--help", "Show this message" ) do .help = true end end begin opts.parse!(args) rescue OptionParser::InvalidOption .help = true .helpMsg = $!. help( , opts ) end if .help help( , opts ) end if args.length > 0 && .help != true .symbol = args[0] else .help = true .helpMsg = "Missing Symbol!" help( , opts ) end end |