Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/na/array.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#remove_bad ⇒ Array
Like Array#compact – removes nil items, but also removes empty strings, zero or negative numbers and FalseClass items.
- #wrap(width, indent, color) ⇒ Object
Instance Method Details
#remove_bad ⇒ Array
Like Array#compact – removes nil items, but also removes empty strings, zero or negative numbers and FalseClass items
10 11 12 |
# File 'lib/na/array.rb', line 10 def remove_bad compact.map { |x| x.is_a?(String) ? x.strip : x }.select(&:good?) end |
#wrap(width, indent, color) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/na/array.rb', line 14 def wrap(width, indent, color) return map { |l| "#{color} #{l.wrap(width, 2)}" } if width < 60 map! do |l| "#{color}#{' ' * indent }• #{l.wrap(width, indent)}{x}" end "\n#{join("\n")}" end |