Returns true
if the named file
exists and is a regular file.
file
can be an IO
object.
If the file
argument is a symbolic link, it will resolve the symbolic link and use the file referenced by the link.
Returns true for dummy encodings. A dummy encoding is an encoding for which character handling is not properly implemented. It is used for stateful encodings.
Encoding::ISO_2022_JP.dummy? #=> true Encoding::UTF_8.dummy? #=> false
Returns the return value of the iterator.
o = Object.new def o.each yield 1 yield 2 yield 3 100 end e = o.to_enum puts e.next #=> 1 puts e.next #=> 2 puts e.next #=> 3 begin e.next rescue StopIteration => ex puts ex.result #=> 100 end
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 the BigDecimal product of self
and value
with a precision of ndigits
decimal digits.
When ndigits
is less than the number of significant digits in the sum, the sum is rounded to that number of digits, according to the current rounding mode; see BigDecimal.mode
.
Examples:
# Set the rounding mode. BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up) b = BigDecimal('555555.555') b.mult(3, 0) # => 0.1666666665e7 b.mult(3, 3) # => 0.167e7 b.mult(3, 6) # => 0.166667e7 b.mult(3, 15) # => 0.1666666665e7 b.mult(3.0, 0) # => 0.1666666665e7 b.mult(Rational(3, 1), 0) # => 0.1666666665e7 b.mult(Complex(3, 0), 0) # => (0.1666666665e7+0.0i)
Returns a string representing the marshalling of self
. See module Marshal
.
inf = BigDecimal('Infinity') # => Infinity dumped = inf._dump # => "9:Infinity" BigDecimal._load(dumped) # => Infinity
Returns true if the given year is a leap year of the proleptic Gregorian calendar.
Date.gregorian_leap?(1900) #=> false Date.gregorian_leap?(2000) #=> true
Returns true if the date is before the day of calendar reform.
Date.new(1582,10,15).julian? #=> false (Date.new(1582,10,15) - 1).julian? #=> true
Returns true if the year is a leap year.
Date.new(2000).leap? #=> true Date.new(2001).leap? #=> false
This method is equivalent to new_start
(Date::JULIAN
).
Returns the number of members.
Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.size #=> 3
Struct#length
is an alias for Struct#size
.
Returns the integer file descriptor for the stream:
$stdin.fileno # => 0 $stdout.fileno # => 1 $stderr.fileno # => 2 File.open('t.txt').fileno # => 10
Alias for Regexp.new
Removes all elements and returns self.
set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}> set.clear #=> #<Set: {}> set #=> #<Set: {}>
Deletes the given object from the set and returns self. Use subtract
to delete many items at once.
Deletes the given object from the set and returns self. If the object is not in the set, returns nil.
Same as sym.to_s.length
.
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
.