Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/cinch/rubyext/string.rb

Overview

Extensions to Ruby’s String class.

Instance Method Summary collapse

Instance Method Details

#irc_downcase(mapping) ⇒ String

Like String#downcase, but respecting different IRC casemaps.

Parameters:

  • mapping (:rfc1459, :"strict-rfc1459", :ascii)

Returns:



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cinch/rubyext/string.rb', line 7

def irc_downcase(mapping)
  case mapping
  when :rfc1459
    self.tr("A-Z[]\\\\^", "a-z{}|~")
  when :"strict-rfc1459"
    self.tr("A-Z[]\\\\", "a-z{}|")
  else
    # when :ascii or unknown/nil
    self.tr("A-Z", "a-z")
  end
end

#irc_upcase(mapping) ⇒ String

Like String#upcase, but respecting different IRC casemaps.

Parameters:

  • mapping (:rfc1459, :"strict-rfc1459", :ascii)

Returns:



23
24
25
26
27
28
29
30
31
32
# File 'lib/cinch/rubyext/string.rb', line 23

def irc_upcase(mapping)
  case mapping
  when :ascii
    self.tr("a-z", "A-Z")
  when :rfc1459
    self.tr("a-z{}|~", "A-Z[]\\\\^")
  when :"strict-rfc1459"
    self.tr("a-z{}|", "A-Z[]\\\\")
  end
end