Class: Externals::Command
- Inherits:
-
Object
- Object
- Externals::Command
- Defined in:
- lib/externals/command.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(name, usage, summary = nil) ⇒ Command
constructor
A new instance of Command.
- #to_s ⇒ Object
Constructor Details
#initialize(name, usage, summary = nil) ⇒ Command
Returns a new instance of Command.
6 7 8 9 10 11 12 13 14 |
# File 'lib/externals/command.rb', line 6 def initialize name, usage, summary = nil @name = name @usage = usage @summary = summary if !@summary @summary, @usage = @usage, @summary end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/externals/command.rb', line 5 def name @name end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
5 6 7 |
# File 'lib/externals/command.rb', line 5 def summary @summary end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/externals/command.rb', line 5 def usage @usage end |
Instance Method Details
#to_s ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/externals/command.rb', line 16 def to_s retval = StringIO.new retval.printf "%-16s", name if usage retval.printf "Usage: #{usage}\n" else dont_pad_first = true end summary.split(/\n/).each_with_index do |line, index| if index == 0 && dont_pad_first retval.printf "%s\n", line.strip else retval.printf "%16s%s\n", '', line.strip end end retval.printf "\n" retval.string end |