lib/texp/base.rb
# Format the list in a human readable format.  By default, use
# "or" as a connecting word. (e.g. ['a', 'b', 'c'] => "a, b, or
# c")
Format the list in a human readable format.  By default, use
"or" as a connecting word.
Format the list in a human readable format . By default use " or " as a connecting word .
def humanize_list(list, connector='or', &block)
      block ||= lambda { |item| item.to_s }
      list = list.sort if list.all? { |item| item.kind_of?(Integer) && item >= 0 }
      case list.size
      when 1
        block.call(list.first)
      else
        list[0...-1].collect { |d|
          block.call(d)
        }.join(", ") +
          " #{connector} " + block.call(list.last)
      end
    end
def humanize_list ( list , connector = 'or' , & block ) block ||= lambda { | item | item . to_s } list = list . sort if list . all? { | item | item . kind_of? ( Integer ) && item >= 0 } case list . size when 1 block . call ( list . first ) else list [ 0 ... - 1 ] . collect { | d | block . call ( d ) } . join ( ", " ) + " #{connector} " + block . call ( list . last ) end end
Format the list in a human readable format.
Format the list in a human readable format .
list
<not_specific>
connector
<not_specific>
block
<not_specific>