Class/Module Index [+]

Quicksearch

Nanoc::ArrayExtensions

Public Instance Methods

checksum() click to toggle source

Calculates the checksum for this array. Any change to this array will result in a different checksum.

@return [String] The checksum for this array

@api private

# File lib/nanoc/base/core_ext/array.rb, line 65
def checksum
  Marshal.dump(self).checksum
end
freeze_recursively() click to toggle source

Freezes the contents of the array, as well as all array elements. The array elements will be frozen using {freeze_recursively} if they respond to that message, or freeze if they do not.

@see Hash#freeze_recursively

@return [void]

@since 3.2.0

# File lib/nanoc/base/core_ext/array.rb, line 47
def freeze_recursively
  return if self.frozen?
  freeze
  each do |value|
    if value.respond_to?(:freeze_recursively)
      value.freeze_recursively
    else
      value.freeze
    end
  end
end
stringify_keys() click to toggle source

@deprecated Renamed to {stringify_keys_recursively}

# File lib/nanoc/base/core_ext/array.rb, line 34
def stringify_keys
  stringify_keys_recursively
end
stringify_keys_recursively() click to toggle source

Returns a new array where all items' keys are recursively converted to strings by calling {Nanoc::ArrayExtensions#stringify_keys_recursively} or {Nanoc::HashExtensions#stringify_keys_recursively}.

@return [Array] The converted array

# File lib/nanoc/base/core_ext/array.rb, line 27
def stringify_keys_recursively
  inject([]) do |array, element|
    array + [ element.respond_to?(:stringify_keys_recursively) ? element.stringify_keys_recursively : element ]
  end
end
symbolize_keys() click to toggle source

@deprecated Renamed to {symbolize_keys_recursively}

# File lib/nanoc/base/core_ext/array.rb, line 18
def symbolize_keys
  symbolize_keys_recursively
end
symbolize_keys_recursively() click to toggle source

Returns a new array where all items' keys are recursively converted to symbols by calling {Nanoc::ArrayExtensions#symbolize_keys_recursively} or {Nanoc::HashExtensions#symbolize_keys_recursively}.

@return [Array] The converted array

# File lib/nanoc/base/core_ext/array.rb, line 9
def symbolize_keys_recursively
  array = []
  self.each do |element|
    array << (element.respond_to?(:symbolize_keys_recursively) ? element.symbolize_keys_recursively : element)
  end
  array
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.