Module: PVN::Optionable::ClassMethods
- Defined in:
- lib/synoption/optionable.rb
Instance Method Summary collapse
- #doc {|@doc| ... } ⇒ Object
- #find_option(optname) ⇒ Object
- #has_option(optname, tag, desc, args = Hash.new) ⇒ Object
- #next_argument_as_integer(ca, cmdargs) ⇒ Object
- #options ⇒ Object
- #to_doc(io = $stdout) ⇒ Object
Instance Method Details
#doc {|@doc| ... } ⇒ Object
42 43 44 45 46 |
# File 'lib/synoption/optionable.rb', line 42 def doc @doc ||= CommandDoc.new yield @doc if block_given? @doc end |
#find_option(optname) ⇒ Object
36 37 38 39 40 |
# File 'lib/synoption/optionable.rb', line 36 def find_option optname self.instance_eval do @option_set.find_by_name optname end end |
#has_option(optname, tag, desc, args = Hash.new) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/synoption/optionable.rb', line 19 def has_option optname, tag, desc, args = Hash.new RIEL::Log.debug "self: #{self}" RIEL::Log.debug "optname: #{optname}" self.instance_eval do @option_set ||= OptionSet.new opt = Option.new optname, tag, desc, args @option_set. << opt RIEL::Log.debug "self: #{self}" RIEL::Log.debug "opt: #{opt.inspect}" RIEL::Log.debug "@option_set: #{@option_set.inspect}" @doc. << opt end end |
#next_argument_as_integer(ca, cmdargs) ⇒ Object
61 62 63 |
# File 'lib/synoption/optionable.rb', line 61 def next_argument_as_integer ca, cmdargs cmdargs.shift.to_i end |
#options ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/synoption/optionable.rb', line 48 def self.instance_eval do @option_set ||= OptionSet.new RIEL::Log.debug "@option_set: #{@option_set}" yield @option_set if block_given? @option_set end end |
#to_doc(io = $stdout) ⇒ Object
57 58 59 |
# File 'lib/synoption/optionable.rb', line 57 def to_doc io = $stdout self.instance_eval { @doc.to_doc io } end |