Returns x/y
or arg
as a Rational
.
Rational(2, 3) #=> (2/3) Rational(5) #=> (5/1) Rational(0.5) #=> (1/2) Rational(0.3) #=> (5404319552844595/18014398509481984) Rational("2/3") #=> (2/3) Rational("0.3") #=> (3/10) Rational("10 cents") #=> ArgumentError Rational(nil) #=> TypeError Rational(1, nil) #=> TypeError Rational("10 cents", exception: false) #=> nil
Syntax of the string form:
string form = extra spaces , rational , extra spaces ; rational = [ sign ] , unsigned rational ; unsigned rational = numerator | numerator , "/" , denominator ; numerator = integer part | fractional part | integer part , fractional part ; denominator = digits ; integer part = digits ; fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; sign = "-" | "+" ; digits = digit , { digit | "_" , digit } ; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; extra spaces = ? \s* ? ;
See also String#to_r
.
Allows setting the gem path searcher. This method is available when requiring ‘rubygems/test_case’
Issues an OPTS command
name Should be the name of the option to set
params is any optional parameters to supply with the option
example: option(‘UTF8’, ‘ON’) => ‘OPTS UTF8 ON’
Sends a OPTIONS request to the path
and gets a response, as an HTTPResponse
object.
Create on demand parser.
Returns the parser to be used.
Unless a URI::Parser
is defined, DEFAULT_PARSER is used.
Merge a set of command options with the set of default options (without modifying the default option hash).
Add the –prerelease option to the option parser.
Run UDP/IP server loop on the given sockets.
The return value of Socket.udp_server_sockets
is appropriate for the argument.
It calls the block for each message received.
Parses a given string as a blob that contains configuration for OpenSSL
.
If the source of the IO
is a file, then consider using parse_config.
Get the names of all sections in the current configuration
Parse the YAML document contained in yaml
. Events will be called on the handler set on the parser instance.
See Psych::Parser
and Psych::Parser#handler
Starts the parser. init
is a data accumulator and is passed to the next event handler (as of Enumerable#inject
).
A detailed description of this gem. See also summary
Set
the version to version
, potentially also setting required_rubygems_version
if version
indicates it is a prerelease.
Parse a raw cookie string into a hash of cookie-name=>Cookie pairs.
cookies = CGI::Cookie.parse("raw_cookie_string") # { "name1" => cookie1, "name2" => cookie2, ... }
Create a DRbUnknownError
exception containing this object.
Turns on net/http 1.2 (Ruby 1.8) features. Defaults to ON in Ruby 1.8 or later.