Results for: "minmax"

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 a string representation of self.

BigDecimal("1234.5678").inspect
  #=> "0.12345678e4"

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)

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)"

Synonym for $stdin.

Print an argument or list of arguments to the default output stream

cgi = CGI.new
cgi.print    # default:  cgi.print == $DEFAULT_OUTPUT.print

Returns a new Date object formed fom the arguments.

With no arguments, returns the date for January 1, -4712:

Date.ordinal.to_s # => "-4712-01-01"

With argument year, returns the date for January 1 of that year:

Date.ordinal(2001).to_s  # => "2001-01-01"
Date.ordinal(-2001).to_s # => "-2001-01-01"

With positive argument yday == n, returns the date for the nth day of the given year:

Date.ordinal(2001, 14).to_s # => "2001-01-14"

With negative argument yday, counts backward from the end of the year:

Date.ordinal(2001, -14).to_s # => "2001-12-18"

Raises an exception if yday is zero or out of range.

See argument start.

Related: Date.jd, Date.new.

Returns a hash of values parsed from string, which should be a valid XML date format:

d = Date.new(2001, 2, 3)
s = d.xmlschema    # => "2001-02-03"
Date._xmlschema(s) # => {:year=>2001, :mon=>2, :mday=>3}

See argument limit.

Related: Date.xmlschema (returns a Date object).

Returns a new Date object with values parsed from string, which should be a valid XML date format:

d = Date.new(2001, 2, 3)
s = d.xmlschema   # => "2001-02-03"
Date.xmlschema(s) # => #<Date: 2001-02-03>

See:

Related: Date._xmlschema (returns a hash).

Returns a string representation of self:

Date.new(2001, 2, 3).inspect
# => "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"

Equivalent to strftime with argument '%Y-%m-%d' (or its shorthand form '%F');

Date.new(2001, 2, 3).iso8601 # => "2001-02-03"

Creates a DateTime object denoting the given ordinal date.

DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
DateTime.ordinal(2001,34,4,5,6,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
DateTime.ordinal(2001,-332,-20,-55,-54,'+7')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>

Creates a new DateTime object by parsing from a string according to some typical XML Schema formats.

DateTime.xmlschema('2001-02-03T04:05:06+07:00')
                          #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>

Raise an ArgumentError when the string length is longer than limit. You can stop this check by passing limit: nil, but note that it may take a long time to parse.

This method is equivalent to strftime(‘%FT%T%:z’). The optional argument n is the number of digits for fractional seconds.

DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9)
                          #=> "2001-02-03T04:05:06.123456789+07:00"

Parses time as a dateTime defined by the XML Schema and converts it to a Time object. The format is a restricted version of the format defined by ISO 8601.

ArgumentError is raised if time is not compliant with the format or if the Time class cannot represent the specified time.

See xmlschema for more information on this format.

require 'time'

Time.xmlschema("2011-10-05T22:26:12-04:00")
#=> 2011-10-05 22:26:12-04:00

You must require ‘time’ to use this method.

Returns a string which represents the time as a dateTime defined by XML Schema:

CCYY-MM-DDThh:mm:ssTZD
CCYY-MM-DDThh:mm:ss.sssTZD

where TZD is Z or [+-]hh:mm.

If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.

fraction_digits specifies a number of digits to use for fractional seconds. Its default value is 0.

require 'time'

t = Time.now
t.iso8601  # => "2011-10-05T22:26:12-04:00"

You must require ‘time’ to use this method.

Returns a string representation of self with subseconds:

t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
t.inspect # => "2000-12-31 23:59:59.5 +000001"

Related: Time#ctime, Time#to_s:

t.ctime   # => "Sun Dec 31 23:59:59 2000"
t.to_s    # => "2000-12-31 23:59:59 +0000"

Returns console size.

You must require ‘io/console’ to use this method.

Tries to set console size. The effect depends on the platform and the running environment.

You must require ‘io/console’ to use this method.

Returns an array of all lines read from the stream.

When called from class IO (but not subclasses of IO), this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

The first argument must be a string that is the path to a file.

With only argument path given, parses lines from the file at the given path, as determined by the default line separator, and returns those lines in an array:

IO.readlines('t.txt')
# => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]

With argument sep given, parses lines as determined by that line separator (see Line Separator):

# Ordinary separator.
IO.readlines('t.txt', 'li')
# =>["First li", "ne\nSecond li", "ne\n\nThird li", "ne\nFourth li", "ne\n"]
# Get-paragraphs separator.
IO.readlines('t.txt', '')
# => ["First line\nSecond line\n\n", "Third line\nFourth line\n"]
# Get-all separator.
IO.readlines('t.txt', nil)
# => ["First line\nSecond line\n\nThird line\nFourth line\n"]

With argument limit given, parses lines as determined by the default line separator and the given line-length limit (see Line Limit):

IO.readlines('t.txt', 7)
# => ["First l", "ine\n", "Second ", "line\n", "\n", "Third l", "ine\n", "Fourth ", "line\n"]

With arguments sep and limit given, parses lines as determined by the given line separator and the given line-length limit (see Line Separator and Line Limit):

Optional keyword arguments opts specify:

Behaves like IO.read, except that the stream is opened in binary mode with ASCII-8BIT encoding.

When called from class IO (but not subclasses of IO), this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

Behaves like IO.write, except that the stream is opened in binary mode with ASCII-8BIT encoding.

When called from class IO (but not subclasses of IO), this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

Writes the given objects to the stream; returns nil. Appends the output record separator $OUTPUT_RECORD_SEPARATOR ($\), if it is not nil. See Line IO.

With argument objects given, for each object:

With default separators:

f = File.open('t.tmp', 'w+')
objects = [0, 0.0, Rational(0, 1), Complex(0, 0), :zero, 'zero']
p $OUTPUT_RECORD_SEPARATOR
p $OUTPUT_FIELD_SEPARATOR
f.print(*objects)
f.rewind
p f.read
f.close

Output:

nil
nil
"00.00/10+0izerozero"

With specified separators:

$\ = "\n"
$, = ','
f.rewind
f.print(*objects)
f.rewind
p f.read

Output:

"0,0.0,0/1,0+0i,zero,zero\n"

With no argument given, writes the content of $_ (which is usually the most recent user input):

f = File.open('t.tmp', 'w+')
gets # Sets $_ to the most recent user input.
f.print
f.close

Formats and writes objects to the stream.

For details on format_string, see Format Specifications.

Search took: 7ms  ·  Total Results: 2220