Class: MyRurema::Options
- Inherits:
-
Object
- Object
- MyRurema::Options
- Defined in:
- lib/myrurema/options.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#no_ask ⇒ Object
Returns the value of attribute no_ask.
-
#open_browser ⇒ Object
Returns the value of attribute open_browser.
-
#port ⇒ Object
Returns the value of attribute port.
-
#rest_args ⇒ Object
Returns the value of attribute rest_args.
-
#rubyver ⇒ Object
Returns the value of attribute rubyver.
-
#ruremadir ⇒ Object
Returns the value of attribute ruremadir.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #usage ⇒ Object
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
3 4 5 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/myrurema/options.rb', line 3 def initialize(argv) @command = nil @open_browser = false @port = nil @dry_run = false @no_ask = false @ruremadir = Pathname("~/.rurema"). @rubyver = RUBY_VERSION @optionparser = OptionParser.new{|o| o. = [ "Usage: rurema [options] <method name or class name>", ].join("\n") o.on("--init", "initialize rurema system"){ @command = :init } o.on("--update", "update documents and database"){ @command = :update } o.on("--server", "start web server"){ @command = :server } o.on("--preview", "render a reference as HTML"){ @command = :preview } o.on("--list", "list all classes"){ @command = :list } o.on("---- (OPTIONS)"){} o.on("--port=N", "port number of the web browser (only meaningful with --server)"){|n| @port = n.to_i } o.on("--browser", "open web browser (only meaningful with --server or --preview)"){ @open_browser = true } o.on("--dry-run", "show commands only"){ @dry_run = true } o.on("--no-ask", "do not ask keyboard input"){ @no_ask = true } o.on("--ruremadir=PATH", "specify rurema directory (default: #{@ruremadir})"){|path| @ruremadir = Pathname(path) } o.on("--rubyver=STR", "specify Ruby version (default: #{@rubyver})"){|str| @rubyver = str } o.on("----- (INFO)"){} o.on("--version", "show version of myrurema"){ puts "myrurema version #{MyRurema::VERSION}" exit } o.on("--help", "show this message"){ puts o exit } } @rest_args = @optionparser.parse(argv) end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def command @command end |
#dry_run ⇒ Object
Returns the value of attribute dry_run.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def dry_run @dry_run end |
#no_ask ⇒ Object
Returns the value of attribute no_ask.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def no_ask @no_ask end |
#open_browser ⇒ Object
Returns the value of attribute open_browser.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def open_browser @open_browser end |
#port ⇒ Object
Returns the value of attribute port.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def port @port end |
#rest_args ⇒ Object
Returns the value of attribute rest_args.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def rest_args @rest_args end |
#rubyver ⇒ Object
Returns the value of attribute rubyver.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def rubyver @rubyver end |
#ruremadir ⇒ Object
Returns the value of attribute ruremadir.
80 81 82 |
# File 'lib/myrurema/options.rb', line 80 def ruremadir @ruremadir end |
Instance Method Details
#usage ⇒ Object
87 88 89 |
# File 'lib/myrurema/options.rb', line 87 def usage puts @optionparser end |