Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/nerdz/config.rb,
lib/nerdz/rebinds.rb

Overview

– Copyleft shura. [ [email protected] ]

This file is part of nerdz.

nerdz is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

nerdz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with nerdz. If not, see <www.gnu.org/licenses/>. ++

Instance Method Summary collapse

Instance Method Details

#esc_split(s) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/nerdz/config.rb', line 21

def esc_split(s)
  return if s.size != 1
  e = Regexp.escape(s.to_s)

  self.scan(/(?:((?:\\#{e}|[^#{e}])*)(?:$|#{e}))/).flatten.tap {|res|
    break res[0..-2] if !self.end_with?(s.to_s)
  }
end

#merge_param(par) ⇒ Object



47
48
49
50
51
# File 'lib/nerdz/rebinds.rb', line 47

def merge_param(par)
  uri = URI.parse(self)
  uri.query = Hash.from_param(uri.query).merge(par).to_param
  uri.to_s
end

#merge_param!(par) ⇒ Object



53
54
55
# File 'lib/nerdz/rebinds.rb', line 53

def merge_param!(par)
  self.replace(self.merge_param(par))
end