Results for: "Data"

This method is equivalent to new_start(Date::ITALY).

Returns the day of the month (1..31) for time.

t = Time.now   #=> 2007-11-19 08:27:03 -0600
t.day          #=> 19
t.mday         #=> 19

Returns the day of the month (1..31) for time.

t = Time.now   #=> 2007-11-19 08:27:03 -0600
t.day          #=> 19
t.mday         #=> 19

Returns an integer representing the day of the week, 0..6, with Sunday == 0.

t = Time.now   #=> 2007-11-20 02:35:35 -0600
t.wday         #=> 2
t.sunday?      #=> false
t.monday?      #=> false
t.tuesday?     #=> true
t.wednesday?   #=> false
t.thursday?    #=> false
t.friday?      #=> false
t.saturday?    #=> false

Returns an integer representing the day of the year, 1..366.

t = Time.now   #=> 2007-11-19 08:32:31 -0600
t.yday         #=> 323

Returns true if time represents Sunday.

t = Time.local(1990, 4, 1)       #=> 1990-04-01 00:00:00 -0600
t.sunday?                        #=> true

Returns true if time represents Monday.

t = Time.local(2003, 8, 4)       #=> 2003-08-04 00:00:00 -0500
t.monday?                        #=> true

Returns true if time represents Tuesday.

t = Time.local(1991, 2, 19)      #=> 1991-02-19 00:00:00 -0600
t.tuesday?                       #=> true

Returns true if time represents Wednesday.

t = Time.local(1993, 2, 24)      #=> 1993-02-24 00:00:00 -0600
t.wednesday?                     #=> true

Returns true if time represents Thursday.

t = Time.local(1995, 12, 21)     #=> 1995-12-21 00:00:00 -0600
t.thursday?                      #=> true

Returns true if time represents Friday.

t = Time.local(1987, 12, 18)     #=> 1987-12-18 00:00:00 -0600
t.friday?                        #=> 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:

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
}

Returns true if ios is associated with a terminal device (tty), false otherwise.

File.new("testfile").isatty   #=> false
File.new("/dev/tty").isatty   #=> true

Returns a MatchData object describing the match, or nil if there was no match. This is equivalent to retrieving the value of the special variable $~ following a normal match. If the second parameter is present, it specifies the position in the string to begin the search.

/(.)(.)(.)/.match("abc")[2]   #=> "b"
/(.)(.)/.match("abc", 1)[2]   #=> "c"

If a block is given, invoke the block with MatchData if match succeed, so that you can write

/M(.*)/.match("Matz") do |m|
  puts m[0]
  puts m[1]
end

instead of

if m = /M(.*)/.match("Matz")
  puts m[0]
  puts m[1]
end

The return value is a value from block execution in this case.

Returns true or false to indicate whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search.

/R.../.match?("Ruby")    #=> true
/R.../.match?("Ruby", 1) #=> false
/P.../.match?("Ruby")    #=> false
$&                       #=> nil

Returns a new set that is a copy of the set, flattening each containing set recursively.

Equivalent to Set#flatten, but replaces the receiver with the result in place. Returns nil if no modifications were made.

Returns sym.to_s.match.

Returns sym.to_s.match?.

Equivalent to sym.to_s.capitalize.to_sym.

See String#capitalize.

Allocates space for a new object of class’s class and does not call initialize on the new instance. The returned object must be an instance of class.

klass = Class.new do
  def initialize(*args)
    @initialized = true
  end

  def initialized?
    @initialized || false
  end
end

klass.allocate.initialized? #=> false

Returns clean pathname of self with consecutive slashes and useless dots removed. The filesystem is not accessed.

If consider_symlink is true, then a more conservative algorithm is used to avoid breaking symbolic linkages. This may retain more .. entries than absolutely necessary, but without accessing the filesystem, this can’t be avoided.

See Pathname#realpath.

The opposite of Pathname#absolute?

It returns false if the pathname begins with a slash.

p = Pathname.new('/im/sure')
p.relative?
    #=> false

p = Pathname.new('not/so/sure')
p.relative?
    #=> true

Creates a full path, including any intermediate directories that don’t yet exist.

See FileUtils.mkpath and FileUtils.mkdir_p

Search took: 15ms  ·  Total Results: 1356