Module: ENVied::Coercer::CoercerExts

Defined in:
lib/envied/coercer.rb

Instance Method Summary collapse

Instance Method Details

#to_array(str) ⇒ Object



6
7
8
# File 'lib/envied/coercer.rb', line 6

def to_array(str)
  str.split(/(?<!\\),/).map{|i| i.gsub(/\\,/,',') }
end

#to_hash(str) ⇒ Object



10
11
12
13
# File 'lib/envied/coercer.rb', line 10

def to_hash(str)
  require 'cgi'
  ::CGI.parse(str).map { |key, values| [key, values[0]] }.to_h
end

#to_uri(str) ⇒ Object



15
16
17
18
# File 'lib/envied/coercer.rb', line 15

def to_uri(str)
  require 'uri'
  ::URI.parse(str)
end