Results for: "tally"

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 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!

Evaluates the string or block in the context of mod, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional filename and lineno parameters set the text for error messages.

class Thing
end
a = %q{def hello() "Hello there!" end}
Thing.module_eval(a)
puts Thing.new.hello()
Thing.module_eval("invalid code", "dummy", 123)

produces:

Hello there!
dummy:123:in `module_eval': undefined local variable
    or method `code' for Thing:Class

Evaluates the string or block in the context of mod, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. module_eval returns the result of evaluating its argument. The optional filename and lineno parameters set the text for error messages.

class Thing
end
a = %q{def hello() "Hello there!" end}
Thing.module_eval(a)
puts Thing.new.hello()
Thing.module_eval("invalid code", "dummy", 123)

produces:

Hello there!
dummy:123:in `module_eval': undefined local variable
    or method `code' for Thing:Class

Makes new_name a new copy of the method old_name. This can be used to retain access to methods that are overridden.

module Mod
  alias_method :orig_exit, :exit #=> :orig_exit
  def exit(code=0)
    puts "Exiting with code #{code}"
    orig_exit(code)
  end
end
include Mod
exit(99)

produces:

Exiting with code 99
No documentation available

Returns a 2-length array; the first item is the result of BigDecimal#precision and the second one is of BigDecimal#scale.

See BigDecimal#precision. See BigDecimal#scale.

Synonym for ENV.

Just returns true. It’s nonsense, but is for symmetry.

Date.valid_jd?(2451944)           #=> true

See also ::jd.

Returns true if the given calendar date is valid, and false if not. Valid in this context is whether the arguments passed to this method would be accepted by ::new.

Date.valid_date?(2001,2,3)        #=> true
Date.valid_date?(2001,2,29)       #=> false
Date.valid_date?(2001,2,-1)       #=> true

See also ::jd and ::civil.

Returns true if the given calendar date is valid, and false if not. Valid in this context is whether the arguments passed to this method would be accepted by ::new.

Date.valid_date?(2001,2,3)        #=> true
Date.valid_date?(2001,2,29)       #=> false
Date.valid_date?(2001,2,-1)       #=> true

See also ::jd and ::civil.

Duplicates self and resets its day of calendar reform.

d = Date.new(1582,10,15)
d.new_start(Date::JULIAN)         #=> #<Date: 1582-10-05 ...>
No documentation available
No documentation available

Returns an array of values from self.

With integer arguments integers given, returns an array containing each value given by one of integers:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.values_at(0, 2)    # => ["Joe Smith", 12345]
joe.values_at(2, 0)    # => [12345, "Joe Smith"]
joe.values_at(2, 1, 0) # => [12345, "123 Maple, Anytown NC", "Joe Smith"]
joe.values_at(0, -3)   # => ["Joe Smith", "Joe Smith"]

Raises IndexError if any of integers is out of range; see Array Indexes.

With integer range argument integer_range given, returns an array containing each value given by the elements of the range; fills with nil values for range elements larger than the structure:

joe.values_at(0..2)
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
joe.values_at(-3..-1)
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
joe.values_at(1..4) # => ["123 Maple, Anytown NC", 12345, nil, nil]

Raises RangeError if any element of the range is negative and out of range; see Array Indexes.

No documentation available
No documentation available

Waits until IO is writable and returns true or false when times out.

Returns the Encoding object that represents the encoding of the file. If io is in write mode and no encoding is specified, returns nil.

Returns the Encoding of the internal string if conversion is specified. Otherwise returns nil.

Dup internal hash.

Clone internal hash.

Returns true if sym starts with one of the prefixes given. Each of the prefixes should be a String or a Regexp.

:hello.start_with?("hell")               #=> true
:hello.start_with?(/H/i)                 #=> true

# returns true if one of the prefixes matches.
:hello.start_with?("heaven", "hell")     #=> true
:hello.start_with?("heaven", "paradise") #=> false

Returns true if this class can be used to create an instance from a serialised JSON string. The class has to implement a class method json_create that expects a hash as first parameter. The hash should include the required data.

See FileTest.readable_real?.

Search took: 4ms  ·  Total Results: 1169