Results for: "String#[]"

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:

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.

See Fiddle::CompositeHandler.sym

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

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.

No documentation available

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"}
No documentation available

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] # => WIN32OLERuntimeError
p obj[0, -1] # => WIN32OLERuntimeError

Retrieve the session data for key key.

No documentation available

Returns data from the table; does not modify the table.


Fetch a Row by Its Integer Index

Returns the nth row of the table if that row exists:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.by_row! # => #<CSV::Table mode:row row_count:4>
table[1] # => #<CSV::Row "Name":"bar" "Value":"1">
table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
table[1] # => #<CSV::Row "Name":"bar" "Value":"1">

Counts backward from the last row if n is negative:

table[-1] # => #<CSV::Row "Name":"baz" "Value":"2">

Returns nil if n is too large or too small:

table[4] # => nil
table[-4] # => nil

Raises an exception if the access mode is :row and n is not an Integer:

table.by_row! # => #<CSV::Table mode:row row_count:4>
# Raises TypeError (no implicit conversion of String into Integer):
table['Name']

Fetch a Column by Its Integer Index

Returns the nth column of the table if that column exists:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.by_col! # => #<CSV::Table mode:col row_count:4>
table[1] # => ["0", "1", "2"]

Counts backward from the last column if n is negative:

table[-2] # => ["foo", "bar", "baz"]

Returns an Array of nil fields if n is too large or too small:

table[4] # => [nil, nil, nil]
table[-4] # => [nil, nil, nil]

Fetch Rows by Range

Returns rows from the table, beginning at row range.first, if those rows exist:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.by_row! # => #<CSV::Table mode:row row_count:4>
rows = table[1..2] # => #<CSV::Row "Name":"bar" "Value":"1">
rows # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]
table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
rows = table[1..2] # => #<CSV::Row "Name":"bar" "Value":"1">
rows # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]

If there are too few rows, returns all from range.start to the end:

rows = table[1..50] # => #<CSV::Row "Name":"bar" "Value":"1">
rows # => [#<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]

Special case: if range.start == table.size, returns an empty Array:

table[table.size..50] # => []

If range.end is negative, calculates the ending index from the end:

rows = table[0..-1]
rows # => [#<CSV::Row "Name":"foo" "Value":"0">, #<CSV::Row "Name":"bar" "Value":"1">, #<CSV::Row "Name":"baz" "Value":"2">]

If range.start is negative, calculates the starting index from the end:

rows = table[-1..2]
rows # => [#<CSV::Row "Name":"baz" "Value":"2">]

If range.start is larger than table.size, returns nil:

table[4..4] # => nil

Fetch Columns by Range

Returns column values from the table, if the column exists; the values are arranged by row:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.by_col!
table[0..1] # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]

Special case: if range.start == headers.size, returns an Array (size: table.size) of empty Arrays:

table[table.headers.size..50] # => [[], [], []]

If range.end is negative, calculates the ending index from the end:

table[0..-1] # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]

If range.start is negative, calculates the starting index from the end:

table[-2..2] # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]

If range.start is larger than table.size, returns an Array of nil values:

table[4..4] # => [nil, nil, nil]

Fetch a Column by Its String Header

Returns column values from the table, if the column exists:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
table.by_col! # => #<CSV::Table mode:col row_count:4>
table['Name'] # => ["foo", "bar", "baz"]
table.by_col_or_row! # => #<CSV::Table mode:col_or_row row_count:4>
col = table['Name']
col # => ["foo", "bar", "baz"]

Modifying the returned column values does not modify the table:

col[0] = 'bat'
col # => ["bat", "bar", "baz"]
table['Name'] # => ["foo", "bar", "baz"]

Returns an Array of nil values if there is no such column:

table['Nosuch'] # => [nil, nil, nil]

Retrieves key from the GW

No documentation available
No documentation available

Accessor method for elements of the tuple.

Retrieves key from the tuple.

Returns a Command instance for command_name

Search took: 6ms  ·  Total Results: 3744