lib/defcli/formatting.rb
# Fit a text in a given width (number of chars).
# @param txt [String]
# @param width [Integer] maximum width
# @return [Array] list of lines of text
Fit a text in a given width (number of chars).
Fit a text in a given width ( number of chars ) .
def format_result_examples(r, color = true)
        examples = if r[:example]
                     [r[:example]]
                   elsif r[:examples]
                     r[:examples]
                   else
                     []
                   end
        if examples.count == 1
          example = tab(fit(examples.first, 75)).join "\n"
          "\n Example:\n#{example}\n"
        elsif examples.count > 1
          examples = examples.map do |e|
            tab(fit(e, 75)).join "\n"
          end.join "\n"
          "\n Examples:\n#{examples}\n"
        end
      end
def format_result_examples ( r , color = true ) examples = if r [ :example ] [ r [ :example ] ] elsif r [ :examples ] r [ :examples ] else [ ] end if examples . count == 1 example = tab ( fit ( examples . first , 75 ) ) . join "\n" "\n Example:\n#{example}\n" elsif examples . count > 1 examples = examples . map do | e | tab ( fit ( e , 75 ) ) . join "\n" end . join "\n" "\n Examples:\n#{examples}\n" end end
Fit a text in a given width (number of chars).
Fit a text in a given width ( number of chars ) .
list of lines of text
list of lines of text
Array
r
<not_specific>
color
<not_specific>
<not_specific>
None
width
<not_specific>
None