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

Synonym for ENV.

Implemented for compatibility; returns true unless jd is invalid (i.e., not a Numeric).

Date.valid_jd?(2451944) # => true

See argument start.

Related: Date.jd.

Returns true if the arguments define a valid ordinal date, false otherwise:

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

See argument start.

Related: Date.jd, Date.new.

Returns true if the arguments define a valid ordinal date, false otherwise:

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

See argument start.

Related: Date.jd, Date.new.

Returns a copy of self with the given start value:

d0 = Date.new(2000, 2, 3)
d0.julian? # => false
d1 = d0.new_start(Date::JULIAN)
d1.julian? # => true

See argument start.

Scrolls the entire scrolls forward n lines.

You must require ‘io/console’ to use this method.

Scrolls the entire scrolls backward n lines.

You must require ‘io/console’ to use this method.

Waits until IO is writable and returns a truthy value or a falsy value when times out.

You must require ‘io/wait’ to use this method.

Returns the Encoding object that represents the encoding of the stream, or nil if the stream is in write mode and no encoding is specified.

See Encodings.

Returns the Encoding object that represents the encoding of the internal string, if conversion is specified, or nil otherwise.

See Encodings.

Dup internal hash.

Clone internal hash.

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 at Array.

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 at Array.

Equivalent to self.to_s.start_with?; see String#start_with?.

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.

Returns the object for which the receiver is the singleton class.

Raises an TypeError if the class is not a singleton class.

class Foo; end

Foo.singleton_class.attached_object        #=> Foo
Foo.attached_object                        #=> TypeError: `Foo' is not a singleton class
Foo.new.singleton_class.attached_object    #=> #<Foo:0x000000010491a370>
TrueClass.attached_object                  #=> TypeError: `TrueClass' is not a singleton class
NilClass.attached_object                   #=> TypeError: `NilClass' is not a singleton class

See FileTest.readable_real?.

See FileTest.world_writable?.

Returns an Addrinfo object for local address obtained by getsockname.

Note that addrinfo.protocol is filled by 0.

TCPSocket.open("www.ruby-lang.org", 80) {|s|
  p s.local_address #=> #<Addrinfo: 192.168.0.129:36873 TCP>
}

TCPServer.open("127.0.0.1", 1512) {|serv|
  p serv.local_address #=> #<Addrinfo: 127.0.0.1:1512 TCP>
}
No documentation available
Search took: 3ms  ·  Total Results: 1359