class String

Public Instance Methods

interpolate(values_hash = {}, options = {}) click to toggle source

matches and replaces placeholders in form of %{foo} or %<foo>

# File lib/string-ext.rb, line 33
def interpolate(values_hash = {}, options = {})
  StringInterpolation.interpolate(self, values_hash, options)
end
to_boolean() click to toggle source

converts string to either TrueClass or FalseClass. If converion can't be made, returns nil

# File lib/string-ext.rb, line 21
def to_boolean
  s = self.downcase.strip
  if s == 'true'
    true
  elsif s == 'false'
    false
  else
    nil
  end
end
to_params() click to toggle source

returns a hash like params containing all the “get” params from a given url Ex:

'http://wiki.rego.co.il/doku.php?id=development:horizon3:plugins:core_extensions:start&do=edit&rev='.to_params
=> {:id=>'development:horizon3:plugins:core_extensions:start', :do=>'edit', :rev=>nil}
# File lib/string-ext.rb, line 7
def to_params
  hash = {}
  params=self.split("?")
  if params.size > 1
    params=params[1].split("&")
    params=params.collect{|param| param.split("=")}
    params.each do |param|
      hash[param[0].to_sym]=param[1]
    end
  end
  hash
end