Module: IRCSupport::Case
- Defined in:
- lib/ircsupport/case.rb
Constant Summary collapse
- @@ascii_map =
['a-z', 'A-Z']
- @@rfc1459_map =
['a-z{}^|', 'A-Z[]~\\']
- @@strict_rfc1459_map =
['a-z{}|', 'A-Z[]\\']
Class Method Summary collapse
-
.irc_downcase(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC lower case.
-
.irc_downcase!(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC lower case, modifying it in place.
-
.irc_eql?(first, second, casemapping = :rfc1459) ⇒ Boolean
Check an IRC identifier (nick, channel) for equality.
-
.irc_upcase(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC upper case.
-
.irc_upcase!(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC upper case, modifying it in place.
Class Method Details
.irc_downcase(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC lower case.
68 69 70 71 72 |
# File 'lib/ircsupport/case.rb', line 68 def irc_downcase(irc_string, casemapping = :rfc1459) result = irc_string.dup irc_downcase!(result, casemapping) return result end |
.irc_downcase!(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC lower case, modifying it in place.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ircsupport/case.rb', line 48 def irc_downcase!(irc_string, casemapping = :rfc1459) case casemapping when :ascii irc_string.tr!(*@@ascii_map.reverse) when :rfc1459 irc_string.tr!(*@@rfc1459_map.reverse) when :'strict-rfc1459' irc_string.tr!(*@@strict_rfc1459_map.reverse) else raise ArgumentError, "Unsupported casemapping #{casemapping}" end return irc_string end |
.irc_eql?(first, second, casemapping = :rfc1459) ⇒ Boolean
Check an IRC identifier (nick, channel) for equality.
80 81 82 |
# File 'lib/ircsupport/case.rb', line 80 def irc_eql?(first, second, casemapping = :rfc1459) return irc_upcase(first, casemapping) == irc_upcase(second, casemapping) end |
.irc_upcase(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC upper case.
37 38 39 40 41 |
# File 'lib/ircsupport/case.rb', line 37 def irc_upcase(irc_string, casemapping = :rfc1459) result = irc_string.dup irc_upcase!(result, casemapping) return result end |
.irc_upcase!(irc_string, casemapping = :rfc1459) ⇒ String
Turn a string into IRC upper case, modifying it in place.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ircsupport/case.rb', line 17 def irc_upcase!(irc_string, casemapping = :rfc1459) case casemapping when :ascii irc_string.tr!(*@@ascii_map) when :rfc1459 irc_string.tr!(*@@rfc1459_map) when :'strict-rfc1459' irc_string.tr!(*@@strict_rfc1459_map) else raise ArgumentError, "Unsupported casemapping #{casemapping}" end return irc_string end |