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:



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

def irc_downcase(mapping)
  case mapping
  when :rfc1459
    tr("A-Z[]\\\\^", "a-z{}|~")
  when :"strict-rfc1459"
    tr("A-Z[]\\\\", "a-z{}|")
  else
    # when :ascii or unknown/nil
    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:



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

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