Results for: "to_proc"

Returns the quoting detection Proc object.

Mounts proc or block on dir and calls it with a WEBrick::HTTPRequest and WEBrick::HTTPResponse

returns the socket address as packed struct sockaddr string.

Addrinfo.tcp("localhost", 80).to_sockaddr
#=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
No documentation available

Args

oth

URI or String

Description

Calculates relative path to oth from self.

Usage

require 'uri'

uri = URI.parse('http://my.example.com')
uri.route_to('http://my.example.com/main.rbx?page=1')
#=> #<URI::Generic /main.rbx?page=1>

Returns self.

If called on a subclass of Array, converts the receiver to an Array object.

Returns the result of interpreting ary as an array of [key, value] pairs.

[[:foo, :bar], [1, 2]].to_h
  # => {:foo => :bar, 1 => 2}

If a block is given, the results of the block on each element of the array will be used as pairs.

["foo", "bar"].to_h {|s| [s.ord, s]}
  # => {102=>"foo", 98=>"bar"}

Creates a string representation of self.

[ "a", "b", "c" ].to_s     #=> "[\"a\", \"b\", \"c\"]"

Returns a string representing obj. The default to_s prints the object’s class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns “main”.

Returns the value of int as a BigDecimal.

require 'bigdecimal'
require 'bigdecimal/util'

42.to_d   # => 0.42e2

See also BigDecimal::new.

Returns a string containing the place-value representation of int with radix base (between 2 and 36).

12345.to_s       #=> "12345"
12345.to_s(2)    #=> "11000000111001"
12345.to_s(8)    #=> "30071"
12345.to_s(10)   #=> "12345"
12345.to_s(16)   #=> "3039"
12345.to_s(36)   #=> "9ix"
78546939656932.to_s(36)  #=> "rubyrules"

Since int is already an Integer, returns self.

to_int is an alias for to_i.

Converts int to a Float. If int doesn’t fit in a Float, the result is infinity.

Returns the value as a rational.

1.to_r        #=> (1/1)
(1<<64).to_r  #=> (18446744073709551616/1)

Returns the value as a string.

Complex(2).to_s                       #=> "2+0i"
Complex('-8/6').to_s                  #=> "-4/3+0i"
Complex('1/2i').to_s                  #=> "0+1/2i"
Complex(0, Float::INFINITY).to_s      #=> "0+Infinity*i"
Complex(Float::NAN, Float::NAN).to_s  #=> "NaN+NaN*i"

Returns the value as an integer if possible (the imaginary part should be exactly zero).

Complex(1, 0).to_i    #=> 1
Complex(1, 0.0).to_i  # RangeError
Complex(1, 2).to_i    # RangeError

Returns the value as a float if possible (the imaginary part should be exactly zero).

Complex(1, 0).to_f    #=> 1.0
Complex(1, 0.0).to_f  # RangeError
Complex(1, 2).to_f    # RangeError

Returns the value as a rational if possible (the imaginary part should be exactly zero).

Complex(1, 0).to_r    #=> (1/1)
Complex(1, 0.0).to_r  # RangeError
Complex(1, 2).to_r    # RangeError

See rationalize.

Returns self.

Complex(2).to_c      #=> (2+0i)
Complex(-8, 6).to_c  #=> (-8+6i)

Returns zero as a complex.

Returns nil represented as a BigDecimal.

require 'bigdecimal'
require 'bigdecimal/util'

nil.to_d   # => 0.0

Always returns zero.

nil.to_i   #=> 0

Always returns zero.

nil.to_f   #=> 0.0

Always returns the empty string.

Always returns an empty array.

nil.to_a   #=> []
Search took: 10ms  ·  Total Results: 1969