Last active
December 20, 2015 10:38
-
-
Save velppa/6116593 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'trollop' | |
| class Test | |
| attr_reader :a | |
| attr_reader :opts | |
| def initialize | |
| @a = 'qwer' | |
| @opts = Trollop::options do | |
| opt :monkey, "Use monkey mode" # a flag --monkey, defaulting to false | |
| opt :goat, "Use goat mode", :default => true # a flag --goat, defaulting to true | |
| opt :num_limbs, "Number of limbs", :default => 4 # an integer --num-limbs <i>, defaulting to 4 | |
| opt :qwer, 'Test', :default => "This is a - #{@a}" | |
| opt :num_thumbs, "Number of thumbs", :type => :int # an integer --num-thumbs <i>, defaulting to nil | |
| end | |
| end | |
| end | |
| a = Test.new() | |
| puts("this is #{a.a} and it's good") | |
| ## if called with no arguments | |
| p a.opts # => { :monkey => false, :goat => true, :num_limbs => 4, :num_thumbs => nil } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Не видит @A на 12-й строке