Class: Cl::Help::Format::Obj
- Inherits:
-
Struct
- Object
- Struct
- Cl::Help::Format::Obj
- Defined in:
- lib/cl/help/format.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
Returns the value of attribute obj.
Instance Method Summary collapse
Instance Attribute Details
#obj ⇒ Object
Returns the value of attribute obj
8 9 10 |
# File 'lib/cl/help/format.rb', line 8 def obj @obj end |
Instance Method Details
#format ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cl/help/format.rb', line 9 def format opts = [] opts << "type: #{type(obj)}" unless obj.type == :flag opts << 'required' if obj.required? opts += Opt.new(obj).format if obj.is_a?(Cl::Opt) opts = opts.join(', ') opts = "(#{opts})" if obj.description && !opts.empty? opts = [obj.description, opts] opts.compact.map(&:strip).join(' ') end |