Class | String
In: | lib/rbot/botuser.rb lib/rbot/core/utils/extends.rb lib/rbot/irc.rb lib/rbot/ircsocket.rb lib/rbot/load-gettext.rb
Parent: | Object

Extension for String class.

String#% method which accept "named argument". The translator can know the meaning of the msgids using "named argument" instead of %s/%d style.

### Methods

% get_html_title has_irc_glob? irc_downcase irc_downcase! irc_send_penalty irc_upcase irc_upcase! ircify_html ircify_html! ircify_html_title riphtml to_irc_auth_command to_irc_casemap to_irc_channel to_irc_channel_topic to_irc_netmask to_irc_regexp to_irc_user

### External Aliases

% | -> | _old_format_m

### Public Instance methods

%(arg)
%(hash)

Format - Uses str as a format specification, and returns the result of applying it to arg. If the format specification contains more than one substitution, then arg must be an Array containing the values to be substituted. See Kernel::sprintf for details of the format string. This is the default behavior of the String class.

- arg: an Array or other class except Hash.
- Returns: formatted String

     (e.g.) "%s, %s" % ["Masao", "Mutoh"]

Also you can use a Hash as the "named argument". This is recommanded way for Ruby-GetText because the translators can understand the meanings of the msgids easily.

- hash: {:key1 => value1, :key2 => value2, … }
- Returns: formatted String

     (e.g.) "%{firstname}, %{familyname}" % {:firstname => "Masao", :familyname => "Mutoh"}

get_html_title()

This method tries to find an HTML title in the string, and returns it if found

has_irc_glob?()

This method checks if the receiver contains IRC glob characters

IRC has a very primitive concept of globs: a `*` stands for "any number of arbitrary characters", a `?` stands for "one and exactly one arbitrary character". These characters can be escaped by prefixing them with a slash (`\`).

A known limitation of this glob syntax is that there is no way to escape the escape character itself, so it‘s not possible to build a glob pattern where the escape character precedes a glob.

irc_downcase(casemap='rfc1459')

This method returns a string which is the downcased version of the receiver, according to the given casemap

irc_downcase!(casemap='rfc1459')

This is the same as the above, except that the string is altered in place

See also the discussion about irc_downcase

irc_send_penalty()

Calculate the penalty which will be assigned to this message by the IRCd

irc_upcase(casemap='rfc1459')

Upcasing functions are provided too

See also the discussion about irc_downcase

irc_upcase!(casemap='rfc1459')

In-place upcasing

See also the discussion about irc_downcase

ircify_html(opts={})

This method will return a purified version of the receiver, with all HTML stripped off and some of it converted to IRC formatting

ircify_html!(opts={})

As above, but modify the receiver

ircify_html_title()

This method returns the IRC-formatted version of an HTML title found in the string

riphtml()

This method will strip all HTML crud from the receiver

to_irc_auth_command()

Returns an Irc::Bot::Auth::Comand from the receiver

to_irc_casemap()

This method returns the Irc::Casemap whose name is the receiver

to_irc_channel(opts={})

We keep extending String, this time adding a method that converts a String into an Irc::Channel object

to_irc_channel_topic()

Returns an Irc::Channel::Topic with self as text

to_irc_netmask(opts={})

We keep extending String, this time adding a method that converts a String into an Irc::Netmask object

to_irc_regexp()

This method is used to convert the receiver into a Regular Expression that matches according to the IRC glob syntax

to_irc_user(opts={})

We keep extending String, this time adding a method that converts a String into an Irc::User object

[Validate]