Results for: "remove_const"

No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available

Add local/remote options to the command line parser.

Convert source_string and return destination_string.

source_string is assumed as a part of source. i.e. :partial_input=>true is specified internally. finish method should be used last.

ec = Encoding::Converter.new("utf-8", "euc-jp")
puts ec.convert("\u3042").dump     #=> "\xA4\xA2"
puts ec.finish.dump                #=> ""

ec = Encoding::Converter.new("euc-jp", "utf-8")
puts ec.convert("\xA4").dump       #=> ""
puts ec.convert("\xA2").dump       #=> "\xE3\x81\x82"
puts ec.finish.dump                #=> ""

ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
puts ec.convert("\xE3").dump       #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x81").dump       #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x82").dump       #=> "\e$B$\"".force_encoding("ISO-2022-JP")
puts ec.finish.dump                #=> "\e(B".force_encoding("ISO-2022-JP")

If a conversion error occur, Encoding::UndefinedConversionError or Encoding::InvalidByteSequenceError is raised. Encoding::Converter#convert doesn’t supply methods to recover or restart from these exceptions. When you want to handle these conversion errors, use Encoding::Converter#primitive_convert.

Equivalent to << with argument n.

No documentation available
No documentation available

Constant time memory comparison. Inputs are hashed using SHA-256 to mask the length of the secret. Returns true if the strings are identical, false otherwise.

A Gem::Version for the currently running RubyGems

Registers the given klass as the class to be instantiated when parsing a URI with the given scheme:

URI.register_scheme('MS_SEARCH', URI::Generic) # => URI::Generic
URI.scheme_list['MS_SEARCH']                   # => URI::Generic

Note that after calling String#upcase on scheme, it must be a valid constant name.

No documentation available
No documentation available

Attempts to return an array, based on the given object.

If object is an array, returns object.

Otherwise if object responds to :to_ary. calls object.to_ary: if the return value is an array or nil, returns that value; if not, raises TypeError.

Otherwise returns nil.

Related: see Methods for Creating an Array.

With a block given, calls the block with each repeated combination of length size of the elements of self; each combination is an array; returns self. The order of the combinations is indeterminate.

If a positive integer argument size is given, calls the block with each size-tuple repeated combination of the elements of self. The number of combinations is (size+1)(size+2)/2.

Examples:

If size is zero, calls the block once with an empty array.

If size is negative, does not call the block:

[0, 1, 2].repeated_combination(-1) {|combination| fail 'Cannot happen' }

With no block given, returns a new Enumerator.

Related: see Methods for Combining.

If object is an Integer object, returns object.

Integer.try_convert(1) # => 1

Otherwise if object responds to :to_int, calls object.to_int and returns the result.

Integer.try_convert(1.25) # => 1

Returns nil if object does not respond to :to_int

Integer.try_convert([]) # => nil

Raises an exception unless object.to_int returns an Integer object.

If object is a String object, returns object.

Otherwise if object responds to :to_str, calls object.to_str and returns the result.

Returns nil if object does not respond to :to_str.

Raises an exception unless object.to_str returns a String object.

Attempts to convert object into an IO object via method to_io; returns the new IO object if successful, or nil otherwise:

IO.try_convert(STDOUT)   # => #<IO:<STDOUT>>
IO.try_convert(ARGF)     # => #<IO:<STDIN>>
IO.try_convert('STDOUT') # => nil

Copies from the given src to the given dst, returning the number of bytes copied.

The examples here use file t.txt as source:

File.read('t.txt')
# => "First line\nSecond line\n\nThird line\nFourth line\n"
File.read('t.txt').size # => 47

If only arguments src and dst are given, the entire source stream is copied:

# Paths.
IO.copy_stream('t.txt', 't.tmp')  # => 47

# IOs (recall that a File is also an IO).
src_io = File.open('t.txt', 'r') # => #<File:t.txt>
dst_io = File.open('t.tmp', 'w') # => #<File:t.tmp>
IO.copy_stream(src_io, dst_io)   # => 47
src_io.close
dst_io.close

With argument src_length a non-negative integer, no more than that many bytes are copied:

IO.copy_stream('t.txt', 't.tmp', 10) # => 10
File.read('t.tmp')                   # => "First line"

With argument src_offset also given, the source stream is read beginning at that offset:

IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11
IO.read('t.tmp')                         # => "Second line"

Returns object if it is a regexp:

Regexp.try_convert(/re/) # => /re/

Otherwise if object responds to :to_regexp, calls object.to_regexp and returns the result.

Returns nil if object does not respond to :to_regexp.

Regexp.try_convert('re') # => nil

Raises an exception unless object.to_regexp returns a regexp.

Search took: 6ms  ·  Total Results: 5438