Results for: "OptionParser"

Returns an array; [num.abs, num.arg].

Returns self.

Returns self.

If numeric is the same type as num, returns an array [numeric, num]. Otherwise, returns an array with both numeric and num represented as Float objects.

This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator.

1.coerce(2.5)   #=> [2.5, 1.0]
1.2.coerce(3)   #=> [3.0, 1.2]
1.coerce(2)     #=> [2, 1]

Returns the receiver. freeze cannot be false.

x.remainder(y) means x-y*(x/y).truncate.

See Numeric#divmod.

Returns true if num is an Integer.

1.0.integer?   #=> false
1.integer?     #=> true

Returns true if num has a zero value.

Returns true if num is greater than 0.

Returns true if num is less than 0.

Returns the numerator.

Convert self to to_enc. to_enc and from_enc are given as constants of Kconv or Encoding objects.

Returns whether self‘s encoding is EUC-JP or not.

Case-insensitive version of String#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from String#casecmp?.

"aBcDeF".casecmp("abcde")     #=> 1
"aBcDeF".casecmp("abcdef")    #=> 0
"aBcDeF".casecmp("abcdefg")   #=> -1
"abcdef".casecmp("ABCDEF")    #=> 0

nil is returned if the two strings have incompatible encodings, or if other_str is not a string.

"foo".casecmp(2)   #=> nil
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}")   #=> nil

Returns true if str and other_str are equal after Unicode case folding, false if they are not equal.

"aBcDeF".casecmp?("abcde")     #=> false
"aBcDeF".casecmp?("abcdef")    #=> true
"aBcDeF".casecmp?("abcdefg")   #=> false
"abcdef".casecmp?("ABCDEF")    #=> true
"\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}")   #=> true

nil is returned if the two strings have incompatible encodings, or if other_str is not a string.

"foo".casecmp?(2)   #=> nil
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}")   #=> nil

Returns true if str has a length of zero.

"hello".empty?   #=> false
" ".empty?       #=> false
"".empty?        #=> true

Iterates through successive values, starting at str and ending at other_str inclusive, passing each value in turn to the block. The String#succ method is used to generate each value. If optional second argument exclusive is omitted or is false, the last value will be included; otherwise it will be excluded.

If no block is given, an enumerator is returned instead.

"a8".upto("b6") {|s| print s, ' ' }
for s in "a8".."b6"
  print s, ' '
end

produces:

a8 a9 b0 b1 b2 b3 b4 b5 b6
a8 a9 b0 b1 b2 b3 b4 b5 b6

If str and other_str contains only ascii numeric characters, both are recognized as decimal numbers. In addition, the width of string (e.g. leading zeros) is handled appropriately.

"9".upto("11").to_a   #=> ["9", "10", "11"]
"25".upto("5").to_a   #=> []
"07".upto("11").to_a  #=> ["07", "08", "09", "10", "11"]

Makes string empty.

a = "abcde"
a.clear    #=> ""

modifies the indexth byte as integer.

Returns a copy of str with all lowercase letters replaced with their uppercase counterparts.

See String#downcase for meaning of options and use with different encodings.

"hEllO".upcase   #=> "HELLO"

Returns a copy of str with all uppercase letters replaced with their lowercase counterparts. Which letters exactly are replaced, and by which other letters, depends on the presence or absence of options, and on the encoding of the string.

The meaning of the options is as follows:

No option

Full Unicode case mapping, suitable for most languages (see :turkic and :lithuanian options below for exceptions). Context-dependent case mapping as described in Table 3-14 of the Unicode standard is currently not supported.

:ascii

Only the ASCII region, i.e. the characters “A” to “Z” and “a” to “z”, are affected. This option cannot be combined with any other option.

:turkic

Full Unicode case mapping, adapted for Turkic languages (Turkish, Azerbaijani, …). This means that upper case I is mapped to lower case dotless i, and so on.

:lithuanian

Currently, just full Unicode case mapping. In the future, full Unicode case mapping adapted for Lithuanian (keeping the dot on the lower case i even if there is an accent on top).

:fold

Only available on downcase and downcase!. Unicode case folding, which is more far-reaching than Unicode case mapping. This option currently cannot be combined with any other option (i.e. there is currently no variant for turkic languages).

Please note that several assumptions that are valid for ASCII-only case conversions do not hold for more general case conversions. For example, the length of the result may not be the same as the length of the input (neither in characters nor in bytes), some roundtrip assumptions (e.g. str.downcase == str.upcase.downcase) may not apply, and Unicode normalization (i.e. String#unicode_normalize) is not necessarily maintained by case mapping operations.

Non-ASCII case mapping/folding is currently supported for UTF-8, UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols. This support will be extended to other encodings.

"hEllO".downcase   #=> "hello"

Returns a copy of str with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase.

See String#downcase for meaning of options and use with different encodings.

"Hello".swapcase          #=> "hELLO"
"cYbEr_PuNk11".swapcase   #=> "CyBeR_pUnK11"

Upcases the contents of str, returning nil if no changes were made.

See String#downcase for meaning of options and use with different encodings.

Downcases the contents of str, returning nil if no changes were made.

See String#downcase for meaning of options and use with different encodings.

Equivalent to String#swapcase, but modifies the receiver in place, returning str, or nil if no changes were made.

See String#downcase for meaning of options and use with different encodings.

Search took: 6ms  ·  Total Results: 4416