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
Returns an UnboundMethod
representing the given instance method in mod.
class Interpreter def do_a() print "there, "; end def do_d() print "Hello "; end def do_e() print "!\n"; end def do_v() print "Dave"; end Dispatcher = { "a" => instance_method(:do_a), "d" => instance_method(:do_d), "e" => instance_method(:do_e), "v" => instance_method(:do_v) } def interpret(string) string.each_char {|b| Dispatcher[b].bind(self).call } end end interpreter = Interpreter.new interpreter.interpret('dave')
produces:
Hello there, Dave!
Removes the method identified by symbol from the current class. For an example, see Module.undef_method
. String arguments are converted to symbols.
Returns the value as an integer (Fixnum
or Bignum
).
If the BigNumber is infinity or NaN, raises FloatDomainError
.
Converts a BigDecimal
to a String of the form “nnnnnn.mmm”. This method is deprecated; use BigDecimal#to_s
(“F”) instead.
require 'bigdecimal' require 'bigdecimal/util' d = BigDecimal.new("3.14") d.to_digits # => "3.14"
return the JSON
value
As int
is already an Integer
, all these methods simply return the receiver.
Deserializes JSON
string by converting numerator value n
, denominator value d
, to a Rational
object.
Returns true if the given ordinal date is valid, and false if not.
Date.valid_ordinal?(2001,34) #=> true Date.valid_ordinal?(2001,366) #=> false
See also jd and ordinal.
Duplicates self and resets its the day of calendar reform.
d = Date.new(1582,10,15) d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...>
This method is equivalent to d - n.
This method is equivalent to d << n
This method is equivalent to d << (n * 12)
Returns a Time
object which denotes self.
Returns self;
Returns a DateTime
object which denotes self.
Deserializes JSON
string by converting Julian year y
, month m
, day d
and Day of Calendar Reform sg
to Date
.
Stores class name (Date
) with Julian year y
, month m
, day d
and Day of Calendar Reform sg
as JSON
string
Returns a Time
object which denotes self.
Returns a Date
object which denotes self.
Returns self.
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
.