Returns true
if self
contains other_string
, false
otherwise:
s = 'foo' s.include?('f') # => true s.include?('fo') # => true s.include?('food') # => false
Returns a left-justified copy of self
.
If integer argument size
is greater than the size (in characters) of self
, returns a new string of length size
that is a copy of self
, left justified and padded on the right with pad_string
:
'hello'.ljust(10) # => "hello " ' hello'.ljust(10) # => " hello " 'hello'.ljust(10, 'ab') # => "helloababa" 'тест'.ljust(10) # => "тест " 'こんにちは'.ljust(10) # => "こんにちは "
If size
is not greater than the size of self
, returns a copy of self
:
'hello'.ljust(5) # => "hello" 'hello'.ljust(1) # => "hello"
Related: String#rjust
, String#center
.
Returns a right-justified copy of self
.
If integer argument size
is greater than the size (in characters) of self
, returns a new string of length size
that is a copy of self
, right justified and padded on the left with pad_string
:
'hello'.rjust(10) # => " hello" 'hello '.rjust(10) # => " hello " 'hello'.rjust(10, 'ab') # => "ababahello" 'тест'.rjust(10) # => " тест" 'こんにちは'.rjust(10) # => " こんにちは"
If size
is not greater than the size of self
, returns a copy of self
:
'hello'.rjust(5, 'ab') # => "hello" 'hello'.rjust(1, 'ab') # => "hello"
Related: String#ljust
, String#center
.
Returns a copy of self
with each character specified by string selector
translated to the corresponding character in string replacements
. The correspondence is positional:
Each occurrence of the first character specified by selector
is translated to the first character in replacements
.
Each occurrence of the second character specified by selector
is translated to the second character in replacements
.
And so on.
Example:
'hello'.tr('el', 'ip') #=> "hippo"
If replacements
is shorter than selector
, it is implicitly padded with its own last character:
'hello'.tr('aeiou', '-') # => "h-ll-" 'hello'.tr('aeiou', 'AA-') # => "hAll-"
Arguments selector
and replacements
must be valid character selectors (see Character Selectors), and may use any of its valid forms, including negation, ranges, and escaping:
# Negation. 'hello'.tr('^aeiou', '-') # => "-e--o" # Ranges. 'ibm'.tr('b-z', 'a-z') # => "hal" # Escapes. 'hel^lo'.tr('\^aeiou', '-') # => "h-l-l-" # Escaped leading caret. 'i-b-m'.tr('b\-z', 'a-z') # => "ibabm" # Escaped embedded hyphen. 'foo\\bar'.tr('ab\\', 'XYZ') # => "fooZYXr" # Escaped backslash.
Like String#tr
, but modifies self
in place. Returns self
if any changes were made, nil
otherwise.
Get the address as an Integer
for the function named name
. The function is searched via dlsym on RTLD_NEXT.
See man(3) dlsym() for more info.
Get the address as an Integer
for the function named name
.
Get the underlying pointer for ruby object val
and return it as a Fiddle::Pointer
object.
Returns integer stored at index.
If start and length are given, a string containing the bytes from start of length will be returned.
Fetch struct member name
if only one argument is specified. If two arguments are specified, the first is an offset and the second is a length and this method returns the string of length
bytes beginning at offset
.
Examples:
my_struct = struct(['int id']).malloc my_struct.id = 1 my_struct['id'] # => 1 my_struct[0, 4] # => "\x01\x00\x00\x00".b
Gets all key-value pairs in a specific section from the current configuration.
Given the following configurating file being loaded:
config = OpenSSL::Config.load('foo.cnf') #=> #<OpenSSL::Config sections=["default"]> puts config.to_s #=> [ default ] # foo=bar
You can get a hash of the specific section like so:
config['default'] #=> {"foo"=>"bar"}
Read a registry value named name and return its value data. The class of the value is the same as the read
method returns.
If the value type is REG_EXPAND_SZ, returns value data whose environment variables are replaced. If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD, REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError
is raised.
The meaning of rtype is the same as for the read
method.
Returns the element of WIN32OLE::Variant
object(OLE array). This method is available only when the variant type of WIN32OLE::Variant
object is VT_ARRAY.
REMARK:
The all indices should be 0 or natural number and lower than or equal to max indices. (This point is different with Ruby Array indices.) obj = WIN32OLE::Variant.new([[1,2,3],[4,5,6]]) p obj[0,0] # => 1 p obj[1,0] # => 4 p obj[2,0] # => WIN32OLE::RuntimeError p obj[0, -1] # => WIN32OLE::RuntimeError
Retrieve the session data for key key
.
Retrieve the code units offset from the given byte offset.
Returns a Command instance for command_name
Return the configuration information for key
.
Queries the configuration for the given key.
Return value associated with key
from database.
Returns nil
if there is no such key
.
See fetch
for more information.