Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/fedux_org_stdlib/core_ext/array/list.rb
Overview
Array
Instance Method Summary collapse
-
#to_list(separator: ', ', last_separator: separator, around: '"') ⇒ String
Convert array to list.
Instance Method Details
#to_list(separator: ', ', last_separator: separator, around: '"') ⇒ String
Convert array to list
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fedux_org_stdlib/core_ext/array/list.rb', line 29 def to_list(separator: ', ', last_separator: separator, around: '"') items = map { |l| format("#{around}%s#{around}", l) } return items.join(last_separator) if items.size <= 2 result = items.slice(0..-2).join(separator) << last_separator result << items.last result end |