Results for: "module_function"

Calls the given block with each successive codepoint from self; each codepoint is the integer value for a character; returns self:

'hello'.each_codepoint {|codepoint| print codepoint, ' ' }
print "\n"
'тест'.each_codepoint {|codepoint| print codepoint, ' ' }
print "\n"
'こんにちは'.each_codepoint {|codepoint| print codepoint, ' ' }
print "\n"

Output:

104 101 108 108 111
1090 1077 1089 1090
12371 12435 12395 12385 12399

Returns an enumerator if no block is given.

Returns true if the named file is readable by the real user and group id of this process. See access(3).

Note that some OS-level security features may cause this to return true even though the file is not readable by the real user/group.

If file_name is readable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).

file_name can be an IO object.

File.world_readable?("/etc/passwd")           #=> 420
m = File.world_readable?("/etc/passwd")
sprintf("%o", m)                              #=> "644"

Returns true if the named file is writable by the real user and group id of this process. See access(3).

Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.

If file_name is writable by others, returns an integer representing the file permission bits of file_name. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).

file_name can be an IO object.

File.world_writable?("/tmp")                  #=> 511
m = File.world_writable?("/tmp")
sprintf("%o", m)                              #=> "777"

Returns true if the named file is executable by the real user and group id of this process. See access(3).

Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe.

Note that some OS-level security features may cause this to return true even though the file is not executable by the real user/group.

Returns default external encoding.

The default external encoding is used by default for strings created from the following locations:

While strings created from these locations will have this encoding, the encoding may not be valid. Be sure to check String#valid_encoding?.

File data written to disk will be transcoded to the default external encoding when written, if default_internal is not nil.

The default external encoding is initialized by the -E option. If -E isn’t set, it is initialized to UTF-8 on Windows and the locale on other operating systems.

Sets default external encoding. You should not set Encoding::default_external in ruby code as strings created before changing the value may have a different encoding from strings created after the value was changed., instead you should use ruby -E to invoke ruby with the correct default_external.

See Encoding::default_external for information on how the default external encoding is used.

Returns default internal encoding. Strings will be transcoded to the default internal encoding in the following places if the default internal encoding is not nil:

Additionally String#encode and String#encode! use the default internal encoding if no encoding is given.

The script encoding (__ENCODING__), not default_internal, is used as the encoding of created strings.

Encoding::default_internal is initialized with -E option or nil otherwise.

Sets default internal encoding or removes default internal encoding when passed nil. You should not set Encoding::default_internal in ruby code as strings created before changing the value may have a different encoding from strings created after the change. Instead you should use ruby -E to invoke ruby with the correct default_internal.

See Encoding::default_internal for information on how the default internal encoding is used.

Returns the locale charmap name. It returns nil if no appropriate information.

Debian GNU/Linux
  LANG=C
    Encoding.locale_charmap  #=> "ANSI_X3.4-1968"
  LANG=ja_JP.EUC-JP
    Encoding.locale_charmap  #=> "EUC-JP"

SunOS 5
  LANG=C
    Encoding.locale_charmap  #=> "646"
  LANG=ja
    Encoding.locale_charmap  #=> "eucJP"

The result is highly platform dependent. So Encoding.find(Encoding.locale_charmap) may cause an error. If you need some encoding object even for unknown locale, Encoding.find(“locale”) can be used.

Returns the list of private methods accessible to obj. If the all parameter is set to false, only those methods in the receiver will be listed.

Returns the list of public methods accessible to obj. If the all parameter is set to false, only those methods in the receiver will be listed.

Similar to method, searches public method only.

Processes a string returned by message.

It may add the class name of the exception to the end of the first line. Also, when highlight keyword is true, it adds ANSI escape sequences to make the message bold.

If you override this method, it must be tolerant for unknown keyword arguments. All keyword arguments passed to full_message are delegated to this method.

This method is overridden by did_you_mean and error_highlight to add their information.

A user-defined exception class can also define their own detailed_message method to add supplemental information. When highlight is true, it can return a string containing escape sequences, but use widely-supported ones. It is recommended to limit the following codes:

Use escape sequences carefully even if highlight is true. Do not use escape sequences to express essential information; the message should be readable even if all escape sequences are ignored.

Return a list of the local variable names defined where this NameError exception was raised.

Internal use only.

Synonym for ENV.

Returns true if the given year is a leap year in the proleptic Gregorian calendar, false otherwise:

Date.gregorian_leap?(2000) # => true
Date.gregorian_leap?(2001) # => false

Related: Date.julian_leap?.

Moves the cursor left n columns.

You must require ‘io/console’ to use this method.

Clears the entire screen and moves the cursor top-left corner.

You must require ‘io/console’ to use this method.

Waits until IO is readable and returns a truthy value, or a falsy value when times out. Returns a truthy value immediately when buffered data is available.

You must require ‘io/wait’ to use this method.

Waits until IO is writable and returns a truthy value or a falsy value when times out.

You must require ‘io/wait’ to use this method.

Calls the given block with each codepoint in the stream; returns self:

f = File.new('t.rus')
a = []
f.each_codepoint {|c| a << c }
a # => [1090, 1077, 1089, 1090]
f.close

Returns an Enumerator if no block is given.

Related: IO#each_byte, IO#each_char.

Removes the named field from the object and returns the value the field contained if it was defined. You may optionally provide a block. If the field is not defined, the result of the block is returned, or a NameError is raised if no block was given.

require "ostruct"

person = OpenStruct.new(name: "John", age: 70, pension: 300)

person.delete_field!("age")  # => 70
person                       # => #<OpenStruct name="John", pension=300>

Setting the value to nil will not remove the attribute:

person.pension = nil
person                 # => #<OpenStruct name="John", pension=nil>

person.delete_field('number')  # => NameError

person.delete_field('number') { 8675_309 } # => 8675309

Deletes every element of the set for which block evaluates to true, and returns self. Returns an enumerator if no block is given.

Search took: 9ms  ·  Total Results: 5313