Class: Comcalc::Client
- Inherits:
-
Object
- Object
- Comcalc::Client
- Defined in:
- lib/comcalc/client.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #execute! ⇒ Object
- #extract_options ⇒ Object
-
#initialize(argv) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(argv) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/comcalc/client.rb', line 11 def initialize(argv) @options = {} @argv = argv end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/comcalc/client.rb', line 9 def @options end |
Instance Method Details
#execute! ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/comcalc/client.rb', line 17 def execute! cli = Comcalc::Cli if @options[:add] cli.new. else puts @optparse exit end end |
#extract_options ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/comcalc/client.rb', line 27 def @optparse = OptionParser.new do |opts| opts. = "Usage: comcalc [options] ..." @options[:add] = false opts.on( '-m', '--menu', 'Add ip to your Connection list' ) @options[:add] = true opts.on( '-h', '--help', 'Display this screen' ) do puts opts exit end opts.on( '-v', '--version', 'Print programs version' ) do puts Comcalc::VERSION exit end end @optparse.parse(@argv) end |