Results for: "fnmatch"

Returns the numerator.

Rational(7).numerator        #=> 7
Rational(7, 1).numerator     #=> 7
Rational(9, -4).numerator    #=> -9
Rational(-2, -10).numerator  #=> 1

Returns the denominator (always positive).

Rational(7).denominator             #=> 1
Rational(7, 1).denominator          #=> 1
Rational(9, -4).denominator         #=> 4
Rational(-2, -10).denominator       #=> 5

Returns true if rat is less than 0.

Returns the absolute value of rat.

(1/2r).abs    #=> (1/2)
(-1/2r).abs   #=> (1/2)

Rational#magnitude is an alias for Rational#abs.

Returns rat truncated (toward zero) to a precision of ndigits decimal digits (default: 0).

When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros.

Returns a rational when ndigits is positive, otherwise returns an integer.

Rational(3).truncate      #=> 3
Rational(2, 3).truncate   #=> 0
Rational(-3, 2).truncate  #=> -1

  #    decimal      -  1  2  3 . 4  5  6
  #                   ^  ^  ^  ^   ^  ^
  #   precision      -3 -2 -1  0  +1 +2

Rational('-123.456').truncate(+1).to_f  #=> -123.4
Rational('-123.456').truncate(-1)       #=> -120

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 hash of parsed elements.

Raise an ArgumentError when the string length is longer than limit. You can stop this check by passing ‘limit: nil`, but note that it may take a long time to parse.

Creates a new Date object by parsing from a string according to some RFC 2616 format.

Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
                                          #=> #<Date: 2001-02-03 ...>

Raise an ArgumentError when the string length is longer than limit. You can stop this check by passing ‘limit: nil`, but note that it may take a long time to parse.

Returns true if the date is Saturday.

This method is equivalent to strftime(‘%a, %d %b %Y %T GMT’). See also RFC 2616.

Creates a new DateTime object by parsing from a string according to some RFC 2616 format.

DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
                          #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>

Raise an ArgumentError when the string length is longer than limit. You can stop this check by passing ‘limit: nil`, but note that it may take a long time to parse.

Parses date as an HTTP-date defined by RFC 2616 and converts it to a Time object.

ArgumentError is raised if date is not compliant with RFC 2616 or if the Time class cannot represent specified date.

See httpdate for more information on this format.

require 'time'

Time.httpdate("Thu, 06 Oct 2011 02:26:12 GMT")
#=> 2011-10-06 02:26:12 UTC

You must require ‘time’ to use this method.

Returns a string which represents the time as RFC 1123 date of HTTP-date defined by RFC 2616:

day-of-week, DD month-name CCYY hh:mm:ss GMT

Note that the result is always UTC (GMT).

require 'time'

t = Time.now
t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"

You must require ‘time’ to use this method.

Returns a new Time object based the on given arguments; its timezone is UTC.

In the first form (up to seven arguments), argument year is required.

Time.utc(2000)                  # => 2000-01-01 00:00:00 UTC
Time.utc(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 UTC

In the second form, all ten arguments are required, though the last four are ignored. This form is useful for creating a time from a 10-element array such as is returned by to_a.

array = Time.now.to_a
p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"]
array[5] = 2000
Time.utc(*array) # => 2000-04-24 13:26:57 UTC

Parameters:

Alias: Time.gm.

Related: Time.local.

Converts time to UTC (GMT), modifying the receiver.

t = Time.now   #=> 2007-11-19 08:18:31 -0600
t.gmt?         #=> false
t.gmtime       #=> 2007-11-19 14:18:31 UTC
t.gmt?         #=> true

t = Time.now   #=> 2007-11-19 08:18:51 -0600
t.utc?         #=> false
t.utc          #=> 2007-11-19 14:18:51 UTC
t.utc?         #=> true

Returns a new Time object representing time in UTC.

t = Time.local(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 -0600
t.gmt?                             #=> false
y = t.getgm                        #=> 2000-01-02 02:15:01 UTC
y.gmt?                             #=> true
t == y                             #=> true

Returns true if time represents a time in UTC (GMT).

t = Time.now                        #=> 2007-11-19 08:15:23 -0600
t.utc?                              #=> false
t = Time.gm(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
t.utc?                              #=> true

t = Time.now                        #=> 2007-11-19 08:16:03 -0600
t.gmt?                              #=> false
t = Time.gm(2000,1,1,20,15,1)       #=> 2000-01-01 20:15:01 UTC
t.gmt?                              #=> true

Returns true if time represents Saturday.

t = Time.local(2006, 6, 10)      #=> 2006-06-10 00:00:00 -0500
t.saturday?                      #=> true

Time

This form accepts a Time object time and optional keyword argument in:

Time.at(Time.new)               # => 2021-04-26 08:52:31.6023486 -0500
Time.at(Time.new, in: '+09:00') # => 2021-04-26 22:52:31.6023486 +0900

Seconds

This form accepts a numeric number of seconds sec and optional keyword argument in:

Time.at(946702800)               # => 1999-12-31 23:00:00 -0600
Time.at(946702800, in: '+09:00') # => 2000-01-01 14:00:00 +0900

Seconds with Subseconds and Units

This form accepts an integer number of seconds sec_i, a numeric number of milliseconds msec, a symbol argument for the subsecond unit type (defaulting to :usec), and an optional keyword argument in:

Time.at(946702800, 500, :millisecond)               # => 1999-12-31 23:00:00.5 -0600
Time.at(946702800, 500, :millisecond, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
Time.at(946702800, 500000)                             # => 1999-12-31 23:00:00.5 -0600
Time.at(946702800, 500000, :usec)                      # => 1999-12-31 23:00:00.5 -0600
Time.at(946702800, 500000, :microsecond)               # => 1999-12-31 23:00:00.5 -0600
Time.at(946702800, 500000, in: '+09:00')               # => 2000-01-01 14:00:00.5 +0900
Time.at(946702800, 500000, :usec, in: '+09:00')        # => 2000-01-01 14:00:00.5 +0900
Time.at(946702800, 500000, :microsecond, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
Time.at(946702800, 500000000, :nsec)                     # => 1999-12-31 23:00:00.5 -0600
Time.at(946702800, 500000000, :nanosecond)               # => 1999-12-31 23:00:00.5 -0600
Time.at(946702800, 500000000, :nsec, in: '+09:00')       # => 2000-01-01 14:00:00.5 +0900
Time.at(946702800, 500000000, :nanosecond, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900

Parameters:

Calls the given block with the value of each member; returns self:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.each {|value| p value }

Output:

"Joe Smith"
"123 Maple, Anytown NC"
12345

Returns an Enumerator if no block is given.

Related: each_pair.

Returns pathname configuration variable using fpathconf().

name should be a constant under Etc which begins with PC_.

The return value is an integer or nil. nil means indefinite limit. (fpathconf() returns -1 but errno is not set.)

require 'etc'
IO.pipe {|r, w|
  p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096
}

Enables/disables echo back. On some platforms, all combinations of this flags and raw/cooked mode may not be valid.

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

Returns true if echo back is enabled.

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

Yields self with disabling echo back.

STDIN.noecho(&:gets)

will read and return a line without echo back.

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

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
Search took: 5ms  ·  Total Results: 1804