Module: OptParse2::Positional
- Defined in:
- lib/optparse2.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "") ⇒ Object
Essentially directly copied from ‘OptParse::Switch`.summarize, except with custom `left`.
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
162 163 164 |
# File 'lib/optparse2.rb', line 162 def name @name end |
Instance Method Details
#summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "") ⇒ Object
Essentially directly copied from ‘OptParse::Switch`.summarize, except with custom `left`
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/optparse2.rb', line 165 def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "") left = ["#{name}"] sdone[name] = true ldone[name] = true right = desc.dup mlen = left.collect {|ss| ss.length}.max.to_i while mlen > width and l = left.shift mlen = left.collect {|ss| ss.length}.max.to_i if l.length == mlen if l.length < width and (r = right[0]) and !r.empty? l = l.to_s.ljust(width) + ' ' + r right.shift end yield(indent + l) end while begin l = left.shift; r = right.shift; l or r end l = l.to_s.ljust(width) + ' ' + r if r and !r.empty? yield(indent + l) end self end |