Results for: "Array.new"

Returns true if the named file is a character device.

file_name can be an IO object.

Returns the next object in the enumerator, and move the internal position forward. When the position reached at the end, StopIteration is raised.

Example

a = [1,2,3]
e = a.to_enum
p e.next   #=> 1
p e.next   #=> 2
p e.next   #=> 3
p e.next   #raises StopIteration

See class-level notes about external iterators.

Rewinds the enumeration sequence to the beginning.

If the enclosed object responds to a “rewind” method, it is called.

Returns any backtrace associated with the exception. The backtrace is an array of strings, each containing either “filename:lineNo: in ‘method”’ or “filename:lineNo.”

def a
  raise "boom"
end

def b
  a()
end

begin
  b()
rescue => detail
  print detail.backtrace.join("\n")
end

produces:

prog.rb:2:in `a'
prog.rb:6:in `b'
prog.rb:10

In the case no backtrace has been set, nil is returned

ex = StandardError.new
ex.backtrace
#=> nil

Return the arguments passed in as the third parameter to the constructor.

Return this SystemCallError’s error number.

Refine mod in the receiver.

Returns a module, where refined methods are defined.

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"
No documentation available

Return the fractional part of the number, as a BigDecimal.

Returns the exponent of the BigDecimal number, as an Integer.

If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string of digits with no leading zeros, then n is the exponent.

Returns the numerator.

Rational(7).numerator        #=> 7
Rational(7, 1).numerator     #=> 7
Rational(9, -4).numerator    #=> -9
Rational(-2, -10).numerator  #=> 1

Returns true if rat is less than 0.

Returns a simpler approximation of the value if the optional argument eps is given (rat-|eps| <= result <= rat+|eps|), self otherwise.

r = Rational(5033165, 16777216)
r.rationalize                    #=> (5033165/16777216)
r.rationalize(Rational('0.01'))  #=> (3/10)
r.rationalize(Rational('0.1'))   #=> (1/3)

Parse an HTTP query string into a hash of key=>value pairs.

params = CGI.parse("query_string")
  # {"name1" => ["value1", "value2", ...],
  #  "name2" => ["value1", "value2", ...], ... }

Creates a date object denoting the present day.

Date.today   #=> #<Date: 2011-06-11 ...>

Parses the given representation of date and time, and returns a hash of parsed elements.

This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use ‘Date._strptime` or `DateTime._strptime` instead of this method as possible.

If the optional second argument is true and the detected year is in the range “00” to “99”, considers the year a 2-digit form and makes it full.

Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}

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.

Parses the given representation of date and time, and creates a date object.

This method *does not* function as a validator. If the input string does not match valid formats strictly, you may get a cryptic result. Should consider to use ‘Date.strptime` instead of this method as possible.

If the optional second argument is true and the detected year is in the range “00” to “99”, considers the year a 2-digit form and makes it full.

Date.parse('2001-02-03')          #=> #<Date: 2001-02-03 ...>
Date.parse('20010203')            #=> #<Date: 2001-02-03 ...>
Date.parse('3rd Feb 2001')        #=> #<Date: 2001-02-03 ...>

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.

Returns the year.

Date.new(2001,2,3).year           #=> 2001
(Date.new(1,1,1) - 1).year        #=> 0

Returns the day of the year (1-366).

Date.new(2001,2,3).yday           #=> 34

Returns the day of the month (1-31).

Date.new(2001,2,3).mday           #=> 3

Returns the day of the month (1-31).

Date.new(2001,2,3).mday           #=> 3

Returns the calendar week based year.

Date.new(2001,2,3).cwyear         #=> 2001
Date.new(2000,1,1).cwyear         #=> 1999

Returns the day of calendar week (1-7, Monday is 1).

Date.new(2001,2,3).cwday          #=> 6

Returns the day of week (0-6, Sunday is zero).

Date.new(2001,2,3).wday           #=> 6
Search took: 5ms  ·  Total Results: 2195