Class: Array

Inherits:
Object show all
Includes:
ArrayCleanup, ArrayNestedHash, ArrayTags, Doing::ChronifyArray
Defined in:
lib/doing/good.rb,
lib/doing/array/array.rb,
lib/doing/chronify/chronify.rb

Overview

Array helpers

Direct Known Subclasses

Doing::Items, Doing::Note

Instance Method Summary collapse

Methods included from Doing::ChronifyArray

#time_string, #to_abbr, #to_natural, #to_years

Instance Method Details

#cap_firstArray

Capitalize first letter of each element

Returns:

  • (Array)

    capitalized items



31
32
33
# File 'lib/doing/array/array.rb', line 31

def cap_first
  map(&:cap_first)
end

#good?Boolean

Tests if object is nil or empty

Returns:

  • (Boolean)

    true if object is defined and has content



59
60
61
# File 'lib/doing/good.rb', line 59

def good?
  !nil? && !empty?
end

#utf8Array

Force UTF-8 encoding of strings in array

Returns:

  • (Array)

    Encoded lines



17
18
19
20
21
22
23
24
# File 'lib/doing/array/array.rb', line 17

def utf8
  c = self.class
  if String.method_defined? :force_encoding
    replace c.new(map(&:utf8))
  else
    self
  end
end