This method is equivalent to new_start
(Date::ITALY
).
Creates a new Time
object with the value given by time
, the given number of seconds_with_frac
, or seconds
and microseconds_with_frac
since the Epoch. seconds_with_frac
and microseconds_with_frac
can be an Integer
, Float
, Rational
, or other Numeric
. non-portable feature allows the offset to be negative on some systems.
If in
argument is given, the result is in that timezone or UTC offset, or if a numeric argument is given, the result is in local time.
Time.at(0) #=> 1969-12-31 18:00:00 -0600 Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600 Time.at(946702800) #=> 1999-12-31 23:00:00 -0600 Time.at(-284061600) #=> 1960-12-31 00:00:00 -0600 Time.at(946684800.2).usec #=> 200000 Time.at(946684800, 123456.789).nsec #=> 123456789 Time.at(946684800, 123456789, :nsec).nsec #=> 123456789
Returns the day of the month (1..n) 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..n) 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
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 a true
or false
indicates 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 sym.to_s.match
.
Returns sym.to_s.match?
.
Same as sym.to_s.capitalize.intern
.
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