Returns the current umask value for this process. If the optional argument is given, set the umask to that value and return the previous value. Umask values are subtracted from the default permissions, so a umask of 0222
would make a file read-only for everyone.
File.umask(0006) #=> 18 File.umask #=> 6
Returns a new string formed by joining the strings using "/"
.
File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
Returns true
if the named file is a symbolic link.
Returns a string which represents the encoding for programmers.
Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>" Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
Search the encoding with specified name. name should be a string.
Encoding.find("US-ASCII") #=> #<Encoding:US-ASCII>
Names which this method accept are encoding names and aliases including following special aliases
default external encoding
default internal encoding
locale encoding
filesystem encoding
An ArgumentError
is raised when no encoding with name. Only Encoding.find("internal")
however returns nil when no encoding named “internal”, in other words, when Ruby has no default internal encoding.
Rewinds the enumeration sequence to the beginning.
If the enclosed object responds to a “rewind” method, it is called.
Creates a printable version of e.
Return this exception’s class name and message
Invokes Module.append_features
on each parameter in reverse order.
Import class refinements from module into the current class or module definition.
Returns the list of Modules
nested at the point of call.
module M1 module M2 $a = Module.nesting end end $a #=> [M1::M2, M1] $a[0].name #=> "M1::M2"
Callback invoked whenever the receiver is included in another module or class. This should be used in preference to Module.append_features
if your code wants to perform some action when a module is included in another.
module A def A.included(mod) puts "#{self} included in #{mod}" end end module Enumerable include A end # => prints "A included in Enumerable"
Returns true
if module is included in mod or one of mod’s ancestors.
module A end class B include A end class C < B end B.include?(A) #=> true C.include?(A) #=> true A.include?(A) #=> false
Returns a string representing this module or class. For basic classes and modules, this is the name. For singletons, we show information on the thing we’re attached to as well.
Limit the number of significant digits in newly created BigDecimal
numbers to the specified value. Rounding is performed as necessary, as specified by BigDecimal.mode
.
A limit of 0, the default, means no upper limit.
The limit specified by this method takes less priority over any limit specified to instance methods such as ceil, floor, truncate, or round.
Returns debugging information about the value as a string of comma-separated values in angle brackets with a leading #:
BigDecimal("1234.5678").inspect #=> "0.12345678e4"
The first part is the address, the second is the value as a string, and the final part ss(mm) is the current number of significant digits and the maximum number of significant digits, respectively.
Returns True if the value is finite (not NaN or infinite).
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 the value as a string for inspection.
Rational(2).inspect #=> "(2/1)" Rational(-8, 6).inspect #=> "(-4/3)" Rational('1/2').inspect #=> "(1/2)"
Creates a date object denoting the given ordinal date.
The day of year should be a negative or a positive number (as a relative day from the end of year when negative). It should not be zero.
Date.ordinal(2001) #=> #<Date: 2001-01-01 ...> Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...> Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...>
Returns a hash of parsed elements.
Creates a new Date
object by parsing from a string according to some typical XML
Schema formats.
Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
Returns the value as a string for inspection.
Date.new(2001,2,3).inspect #=> "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>" DateTime.new(2001,2,3,4,5,6,'-7').inspect #=> "#<DateTime: 2001-02-03T04:05:06-07:00 ((2451944j,39906s,0n),-25200s,2299161j)>"
This method is equivalent to strftime(‘%F’).