Module: Arrow::ArrayUtilities

Defined in:
lib/arrow/mixins.rb

Overview

A collection of utilities for working with Arrays.

Instance Method Summary

Instance Method Details

- (Object) stringify_array(array)

Return a version of the given array with any Symbols contained in it turned into Strings.



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/arrow/mixins.rb', line 96

def stringify_array( array )
  return array.collect do |item|
    case item
    when Symbol
      item.to_s
    when Array
      stringify_array( item )
    else
      item
    end
  end
end

- (Object) symbolify_array(array)

Return a version of the given array with any Strings contained in it turned into Symbols.



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/arrow/mixins.rb', line 112

def symbolify_array( array )
  return array.collect do |item|
    case item
    when String
      item.to_sym
    when Array
      symbolify_array( item )
    else
      item
    end
  end
end