Results for: "tally"

Returns the hash of available encoding alias and original encoding name.

Encoding.aliases
#=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1968"=>"US-ASCII",
      "SJIS"=>"Windows-31J", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}

Return the status value associated with this system exit.

In the first form, returns an array of the names of all constants accessible from the point of call. This list includes the names of all modules and classes defined in the global scope.

Module.constants.first(4)
   # => [:ARGF, :ARGV, :ArgumentError, :Array]

Module.constants.include?(:SEEK_SET)   # => false

class IO
  Module.constants.include?(:SEEK_SET) # => true
end

The second form calls the instance method constants.

Returns an array of the names of the constants accessible in mod. This includes the names of constants in any included modules (example at start of section), unless the inherit parameter is set to false.

The implementation makes no guarantees about the order in which the constants are yielded.

IO.constants.include?(:SYNC)        #=> true
IO.constants(false).include?(:SYNC) #=> false

Also see Module#const_defined?.

Returns the number of decimal digits following the decimal digits in self.

BigDecimal("0").scale         # => 0
BigDecimal("1").scale         # => 1
BigDecimal("1.1").scale       # => 1
BigDecimal("3.1415").scale    # => 4
BigDecimal("-1e20").precision # => 0
BigDecimal("1e-20").precision # => 20
BigDecimal("Infinity").scale  # => 0
BigDecimal("-Infinity").scale # => 0
BigDecimal("NaN").scale       # => 0

Returns a simpler approximation of the value if the optional argument eps is given (rat-|eps| <= result <= rat+|eps|), self otherwise.

r = Rational(5033165, 16777216)
r.rationalize                    #=> (5033165/16777216)
r.rationalize(Rational('0.01'))  #=> (3/10)
r.rationalize(Rational('0.1'))   #=> (1/3)

Returns a new Date object formed fom the arguments.

With no arguments, returns the date for January 1, -4712:

Date.ordinal.to_s # => "-4712-01-01"

With argument year, returns the date for January 1 of that year:

Date.ordinal(2001).to_s  # => "2001-01-01"
Date.ordinal(-2001).to_s # => "-2001-01-01"

With positive argument yday == n, returns the date for the nth day of the given year:

Date.ordinal(2001, 14).to_s # => "2001-01-14"

With negative argument yday, counts backward from the end of the year:

Date.ordinal(2001, -14).to_s # => "2001-12-18"

Raises an exception if yday is zero or out of range.

See argument start.

Related: Date.jd, Date.new.

Returns a new Date object constructed from the arguments.

Argument cwyear gives the year, and should be an integer.

Argument cweek gives the index of the week within the year, and should be in range (1..53) or (-53..-1); in some years, 53 or -53 will be out-of-range; if negative, counts backward from the end of the year:

Date.commercial(2022, 1, 1).to_s  # => "2022-01-03"
Date.commercial(2022, 52, 1).to_s # => "2022-12-26"

Argument cwday gives the indes of the weekday within the week, and should be in range (1..7) or (-7..-1); 1 or -7 is Monday; if negative, counts backward from the end of the week:

Date.commercial(2022, 1, 1).to_s  # => "2022-01-03"
Date.commercial(2022, 1, -7).to_s # => "2022-01-03"

When cweek is 1:

See argument start.

Related: Date.jd, Date.new, Date.ordinal.

Returns the Julian start date for calendar reform; if not an infinity, the returned value is suitable for passing to Date#jd:

d = Date.new(2001, 2, 3, Date::ITALY)
s = d.start     # => 2299161.0
Date.jd(s).to_s # => "1582-10-15"

d = Date.new(2001, 2, 3, Date::ENGLAND)
s = d.start     # => 2361222.0
Date.jd(s).to_s # => "1752-09-14"

Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
Date.new(2001, 2, 3, Date::JULIAN).start    # => Infinity

See argument start.

Creates a DateTime object denoting the given ordinal date.

DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
DateTime.ordinal(2001,34,4,5,6,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
DateTime.ordinal(2001,-332,-20,-55,-54,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>

Creates a DateTime object denoting the given week date.

DateTime.commercial(2001) #=> #<DateTime: 2001-01-01T00:00:00+00:00 ...>
DateTime.commercial(2002) #=> #<DateTime: 2001-12-31T00:00:00+00:00 ...>
DateTime.commercial(2001,5,6,4,5,6,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>

Like Time.utc, except that the returned Time object has the local timezone, not the UTC timezone:

# With seven arguments.
Time.local(0, 1, 2, 3, 4, 5, 6)
# => 0000-01-02 03:04:05.000006 -0600
# With exactly ten arguments.
Time.local(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
# => 0005-04-03 02:01:00 -0600

With no argument given:

With argument zone given, returns the new Time object created by converting self to the given time zone:

t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
t.localtime("-09:00")               # => 2000-01-01 11:15:01 -0900

For forms of argument zone, see Timezone Specifiers.

Returns a new Time object representing the value of self converted to a given timezone; if zone is nil, the local timezone is used:

t = Time.utc(2000)                    # => 2000-01-01 00:00:00 UTC
t.getlocal                            # => 1999-12-31 18:00:00 -0600
t.getlocal('+12:00')                  # => 2000-01-01 12:00:00 +1200

For forms of argument zone, see Timezone Specifiers.

Returns status information for ios as an object of type File::Stat.

f = File.new("testfile")
s = f.stat
"%o" % s.mode   #=> "100644"
s.blksize       #=> 4096
s.atime         #=> Wed Apr 09 08:53:54 CDT 2003

Immediately writes to disk all data buffered in the stream, via the operating system’s: fdatasync(2), if supported, otherwise via fsync(2), if supported; otherwise raises an exception.

Reads up to maxlen bytes from the stream; returns a string (either a new string or the given out_string). Its encoding is:

With the single non-negative integer argument maxlen given, returns a new string:

f = File.new('t.txt')
f.readpartial(20) # => "First line\nSecond l"
f.readpartial(20) # => "ine\n\nFourth line\n"
f.readpartial(20) # => "Fifth line\n"
f.readpartial(20) # Raises EOFError.
f.close

With both argument maxlen and string argument out_string given, returns modified out_string:

f = File.new('t.txt')
s = 'foo'
f.readpartial(20, s) # => "First line\nSecond l"
s = 'bar'
f.readpartial(0, s)  # => ""
f.close

This method is useful for a stream such as a pipe, a socket, or a tty. It blocks only when no data is immediately available. This means that it blocks only when all of the following are true:

When blocked, the method waits for either more data or EOF on the stream:

When not blocked, the method responds immediately:

Note that this method is similar to sysread. The differences are:

The latter means that readpartial is non-blocking-flag insensitive. It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode.

Examples:

#                        # Returned      Buffer Content    Pipe Content
r, w = IO.pipe           #
w << 'abc'               #               ""                "abc".
r.readpartial(4096)      # => "abc"      ""                ""
r.readpartial(4096)      # (Blocks because buffer and pipe are empty.)

#                        # Returned      Buffer Content    Pipe Content
r, w = IO.pipe           #
w << 'abc'               #               ""                "abc"
w.close                  #               ""                "abc" EOF
r.readpartial(4096)      # => "abc"      ""                 EOF
r.readpartial(4096)      # raises EOFError

#                        # Returned      Buffer Content    Pipe Content
r, w = IO.pipe           #
w << "abc\ndef\n"        #               ""                "abc\ndef\n"
r.gets                   # => "abc\n"    "def\n"           ""
w << "ghi\n"             #               "def\n"           "ghi\n"
r.readpartial(4096)      # => "def\n"    ""                "ghi\n"
r.readpartial(4096)      # => "ghi\n"    ""                ""

Returns the current position (in bytes) in self (see Position):

f = File.open('t.txt')
f.tell # => 0
f.gets # => "First line\n"
f.tell # => 12
f.close

Related: IO#pos=, IO#seek.

IO#pos is an alias for IO#tell.

Replaces the elements with ones returned by collect(). Returns an enumerator if no block is given.

Returns the values in self as an array:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345]

Struct#values and Struct#deconstruct are aliases for Struct#to_a.

Related: members.

Returns pathname. This method is deprecated and will be removed in Ruby 3.2.

Returns pathname. This method is deprecated and will be removed in Ruby 3.2.

Returns the real (absolute) pathname for self in the actual filesystem.

Does not contain symlinks or useless dots, .. and ..

All components of the pathname must exist when this method is called.

Returns the real (absolute) pathname of self in the actual filesystem.

Does not contain symlinks or useless dots, .. and ..

The last component of the real pathname can be nonexistent.

Returns a File::Stat object.

See File.stat.

Search took: 3ms  ·  Total Results: 1206