class String
Public Instance Methods
to_array()
click to toggle source
# File lib/to_array.rb, line 2 def to_array if self[0] != "[" || self[-1] != "]" raise ArgumentError.new("invalid value for `str_to_array': '#{self}'") end begin arr = self.chomp.gsub(/"|^\[|\]$/, '') arr = arr.split(/,[\s]*/) return arr rescue raise ArgumentError.new("invalid value for `str_to_array': '#{self}'") end end