Results for: "max_by"

If the stream begins with a BOM (byte order marker), consumes the BOM and sets the external encoding accordingly; returns the result encoding if found, or nil otherwise:

File.write('t.tmp', "\u{FEFF}abc")
io ='t.tmp', 'rb')
io.set_encoding_by_bom # => #<Encoding:UTF-8>

File.write('t.tmp', 'abc')
io ='t.tmp', 'rb')
io.set_encoding_by_bom # => nil

Raises an exception if the stream is not binmode or its encoding has already been set.

No documentation available
No documentation available
No documentation available

Removes the gemspec matching full_name from the dependency list

Find the best specification matching a name and requirements. Raises if the dependency doesn’t resolve to a valid specification.

Return the best specification that contains the file matching path.

No documentation available

Returns a duplicate of self, in mixed mode (see Mixed Mode):

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true).by_col!
table.mode # => :col
dup_table = table.by_col_or_row
dup_table.mode # => :col_or_row
dup_table.equal?(table) # => false # It's a dup

This may be used to chain method calls without changing the mode (but also will affect performance and memory usage):


Also note that changes to the duplicate table will not affect the original.

Sets the mode for self to mixed mode (see Mixed Mode); returns self:

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true).by_col!
table.mode # => :col
table1 = table.by_col_or_row!
table.mode # => :col_or_row
table1.equal?(table) # => true # Returned self
No documentation available
No documentation available

Remove everything in the DependencyList that matches but doesn’t satisfy items in dependencies (a hash of gem names to arrays of dependencies).

Returns every spec that matches name and optional requirements.

Find the best specification matching a full_name.

Return the best specification that contains the file matching path amongst the specs that are not activated.

Returns every spec that has the given full_name

No documentation available

mkmf.rb is used by Ruby C extensions to generate a Makefile which will correctly compile and link the C extension to Ruby and a third-party library.

Raised when a gem dependencies file specifies a ruby version that does not match the current version.

The command manager registers and installs all the individual sub-commands supported by the gem command.

Extra commands can be provided by writing a rubygems_plugin.rb file in an installed gem. You should register your command against the Gem::CommandManager instance, like this:

# file rubygems_plugin.rb
require 'rubygems/command_manager'

Gem::CommandManager.instance.register_command :edit

You should put the implementation of your command in rubygems/commands.

# file rubygems/commands/edit_command.rb
class Gem::Commands::EditCommand < Gem::Command
  # ...

See Gem::Command for instructions on writing gem commands.

Raised when encountering Ruby code with an invalid syntax.


raises the exception:

SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end
No documentation available
No documentation available

BigDecimal provides arbitrary-precision floating point decimal arithmetic.


Ruby provides built-in support for arbitrary precision integer arithmetic.

For example:

42**13  #=>   1265437718438866624512

BigDecimal provides similar support for very large or very accurate floating point numbers.

Decimal arithmetic is also useful for general calculation, because it provides the correct answers people expect–whereas normal binary floating point arithmetic often introduces subtle errors because of the conversion between base 10 and base 2.

For example, try:

sum = 0
10_000.times do
  sum = sum + 0.0001
print sum #=> 0.9999999999999062

and contrast with the output from:

require 'bigdecimal'

sum = BigDecimal("0")
10_000.times do
  sum = sum + BigDecimal("0.0001")
print sum #=> 0.1E1


(BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true

(1.2 - 1.0) == 0.2 #=> false

A Note About Precision

For a calculation using a BigDecimal and another value, the precision of the result depends on the type of value:

Special features of accurate decimal arithmetic

Because BigDecimal is more accurate than normal binary floating point arithmetic, it requires some special values.


BigDecimal sometimes needs to return infinity, for example if you divide a value by zero.

BigDecimal("1.0") / BigDecimal("0.0")  #=> Infinity
BigDecimal("-1.0") / BigDecimal("0.0")  #=> -Infinity

You can represent infinite numbers to BigDecimal using the strings 'Infinity', '+Infinity' and '-Infinity' (case-sensitive)

Not a Number

When a computation results in an undefined value, the special value NaN (for ‘not a number’) is returned.


BigDecimal("0.0") / BigDecimal("0.0") #=> NaN

You can also create undefined values.

NaN is never considered to be the same as any other value, even NaN itself:

n = BigDecimal('NaN')
n == 0.0 #=> false
n == n #=> false

Positive and negative zero

If a computation results in a value which is too small to be represented as a BigDecimal within the currently specified limits of precision, zero must be returned.

If the value which is too small to be represented is negative, a BigDecimal value of negative zero is returned.

BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0

If the value is positive, a value of positive zero is returned.

BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0

(See BigDecimal.mode for how to specify limits of precision.)

Note that -0.0 and 0.0 are considered to be the same for the purposes of comparison.

Note also that in mathematics, there is no particular concept of negative or positive zero; true mathematical zero has no sign.


When you require bigdecimal/util, the to_d method will be available on BigDecimal and the native Integer, Float, Rational, and String classes:

require 'bigdecimal/util'

42.to_d         # => 0.42e2
0.5.to_d        # => 0.5e0
(2/3r).to_d(3)  # => 0.667e0
"0.5".to_d      # => 0.5e0

Methods for Working with JSON

These methods are provided by the JSON gem. To make these methods available:

require 'json/add/bigdecimal'

Copyright © 2002 by Shigeo Kobayashi <>.

BigDecimal is released under the Ruby and 2-clause BSD licenses. See LICENSE.txt for details.

Maintained by mrkn <> and ruby-core members.

Documented by zzak <>, mathew <>, and many other contributors.

Search took: 7ms  ·  Total Results: 593