Returns an array of the names of class variables in mod. This includes the names of class variables in any included modules, unless the inherit parameter is set to false
.
class One @@var1 = 1 end class Two < One @@var2 = 2 end One.class_variables #=> [:@@var1] Two.class_variables #=> [:@@var2, :@@var1] Two.class_variables(false) #=> [:@@var2]
Makes a list of existing constants public.
Makes a list of existing constants private.
Makes a list of existing constants deprecated. Attempt to refer to them will produce a warning.
module HTTP NotFound = Exception.new NOT_FOUND = NotFound # previous version of the library used this name deprecate_constant :NOT_FOUND end HTTP::NOT_FOUND # warning: constant HTTP::NOT_FOUND is deprecated
Returns true
if mod is a singleton class or false
if it is an ordinary class or module.
class C end C.singleton_class? #=> false C.singleton_class.singleton_class? #=> true
Execute the provided block, but preserve the precision limit
BigDecimal.limit(100) puts BigDecimal.limit BigDecimal.save_limit do BigDecimal.limit(200) puts BigDecimal.limit end puts BigDecimal.limit
Returns the number of decimal significant digits in self
.
BigDecimal("0").scale # => 0 BigDecimal("1").scale # => 1 BigDecimal("1.1").scale # => 2 BigDecimal("3.1415").scale # => 5 BigDecimal("-1e20").precision # => 1 BigDecimal("1e-20").precision # => 1 BigDecimal("Infinity").scale # => 0 BigDecimal("-Infinity").scale # => 0 BigDecimal("NaN").scale # => 0
Converts a BigDecimal
to a String
of the form “nnnnnn.mmm”. This method is deprecated; use BigDecimal#to_s
(“F”) instead.
require 'bigdecimal/util' d = BigDecimal("3.14") d.to_digits # => "3.14"
return the JSON
value
Deserializes JSON
string by converting numerator value n
, denominator value d
, to a Rational
object.
Returns a hash, that will be turned into a JSON
object and represent this object.
Return the accept character set for all new CGI
instances.
This method is equivalent to d >> (n * 12).
Date.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...> Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...> Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
See also Date#>>
.
This method is equivalent to d << (n * 12).
Date.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...> Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...> Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
See also Date#<<
.
Deserializes JSON
string by converting Julian year y
, month m
, day d
and Day of Calendar Reform sg
to Date
.
Returns a hash, that will be turned into a JSON
object and represent this object.
Stores class name (Date
) with Julian year y
, month m
, day d
and Day of Calendar Reform sg
as JSON
string
Deserializes JSON
string by converting year y
, month m
, day d
, hour H
, minute M
, second S
, offset of
and Day of Calendar Reform sg
to DateTime
.
Returns a hash, that will be turned into a JSON
object and represent this object.