Creates a class to wrap the C union described by signature
.
MyUnion = union ['int i', 'char c']
Generate a Table Caption element as a string.
align
can be a string, giving the alignment of the caption (one of top, bottom, left, or right). It can be a hash of all the attributes of the element. Or it can be omitted.
The body of the element is provided by the passed-in no-argument block.
caption("left") { "Capital Cities" } # => <CAPTION ALIGN=\"left\">Capital Cities</CAPTION>
Sets OptionParser
object, when opt
is false
or nil
, methods OptionParser::Arguable#options
and OptionParser::Arguable#options=
are undefined. Thus, there is no ways to access the OptionParser
object via the receiver object.
Actual OptionParser
object, automatically created if nonexistent.
If called with a block, yields the OptionParser
object and returns the result of the block. If an OptionParser::ParseError
exception occurs in the block, it is rescued, a error message printed to STDERR and nil
returned.
<!NOTATION …>
<!NOTATION …>
Appends the elements of other_ary
s to self
.
[ "a", "b" ].concat( ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat( ["b"], ["c", "d"]) #=> [ "a", "b", "c", "d" ] [ "a" ].concat #=> [ "a" ] a = [ 1, 2, 3 ] a.concat( [ 4, 5 ]) a #=> [ 1, 2, 3, 4, 5 ] a = [ 1, 2 ] a.concat(a, a) #=> [1, 2, 1, 2, 1, 2]
See also Array#+
.
Returns int
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 self
when ndigits
is zero or positive.
1.truncate #=> 1 1.truncate(2) #=> 1 18.truncate(-1) #=> 10 (-18).truncate(-1) #=> -10
Returns num
truncated (toward zero) to a precision of ndigits
decimal digits (default: 0).
Numeric
implements this by converting its value to a Float
and invoking Float#truncate
.
Concatenates the given object(s) to str. If an object is an Integer
, it is considered a codepoint and converted to a character before concatenation.
concat
can take multiple arguments, and all the arguments are concatenated in order.
a = "hello " a.concat("world", 33) #=> "hello world!" a #=> "hello world!" b = "sn" b.concat("_", b, "_", b) #=> "sn_sn_sn"
See also String#<<
, which takes a single argument.
Returns float
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 floating point number when ndigits
is positive, otherwise returns an integer.
2.8.truncate #=> 2 (-2.8).truncate #=> -2 1.234567.truncate(2) #=> 1.23 34567.89.truncate(-2) #=> 34500
Note that the limited precision of floating point arithmetic might lead to surprising results:
(0.3 / 0.1).truncate #=> 2 (!)
Returns the change time for the named file (the time at which directory information about the file was changed, not the file itself).
file_name can be an IO
object.
Note that on Windows (NTFS), returns creation time (birth time).
File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
Truncates the file file_name to be at most integer bytes long. Not available on all platforms.
f = File.new("out", "w") f.write("1234567890") #=> 10 f.close #=> nil File.truncate("out", 5) #=> 0 File.size("out") #=> 5
Returns the change time for file (that is, the time directory information about the file was changed, not the file itself).
Note that on Windows (NTFS), returns creation time (birth time).
File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
Truncates file to at most integer bytes. The file must be opened for writing. Not available on all platforms.
f = File.new("out", "w") f.syswrite("1234567890") #=> 10 f.truncate(5) #=> 0 f.close() #=> nil File.size("out") #=> 5
Truncate to the nearest integer (by default), returning the result as a BigDecimal
.
BigDecimal('3.14159').truncate #=> 3 BigDecimal('8.7').truncate #=> 8 BigDecimal('-9.9').truncate #=> -9
If n is specified and positive, the fractional part of the result has no more than that many digits.
If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result.
BigDecimal('3.14159').truncate(3) #=> 3.141 BigDecimal('13345.234').truncate(-2) #=> 13300.0
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 string in asctime(3) format (but without “n0” at the end). This method is equivalent to strftime(‘%c’).
See also asctime(3) or ctime(3).
Returns a string in asctime(3) format (but without “n0” at the end). This method is equivalent to strftime(‘%c’).
See also asctime(3) or ctime(3).
Returns a canonical string representation of time.
Time.now.asctime #=> "Wed Apr 9 08:56:03 2003" Time.now.ctime #=> "Wed Apr 9 08:56:03 2003"
Returns a canonical string representation of time.
Time.now.asctime #=> "Wed Apr 9 08:56:03 2003" Time.now.ctime #=> "Wed Apr 9 08:56:03 2003"
Provides a mechanism for issuing low-level commands to control or query I/O devices. Arguments and results are platform dependent. If arg is a number, its value is passed directly. If it is a string, it is interpreted as a binary sequence of bytes. On Unix platforms, see ioctl(2)
for details. Not implemented on all platforms.