Results for: "tally"

Returns the value of the given instance variable, or nil if the instance variable is not set. The @ part of the variable name should be included for regular instance variables. Throws a NameError exception if the supplied symbol is not valid as an instance variable name. String arguments are converted to symbols.

class Fred
  def initialize(p1, p2)
    @a, @b = p1, p2
  end
end
fred = Fred.new('cat', 99)
fred.instance_variable_get(:@a)    #=> "cat"
fred.instance_variable_get("@b")   #=> 99

Sets the instance variable named by symbol to the given object. This may circumvent the encapsulation intended by the author of the class, so it should be used with care. The variable does not have to exist prior to this call. If the instance variable name is passed as a string, that string is converted to a symbol.

class Fred
  def initialize(p1, p2)
    @a, @b = p1, p2
  end
end
fred = Fred.new('cat', 99)
fred.instance_variable_set(:@a, 'dog')   #=> "dog"
fred.instance_variable_set(:@c, 'cat')   #=> "cat"
fred.inspect                             #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"

Returns true if the given instance variable is defined in obj. String arguments are converted to symbols.

class Fred
  def initialize(p1, p2)
    @a, @b = p1, p2
  end
end
fred = Fred.new('cat', 99)
fred.instance_variable_defined?(:@a)    #=> true
fred.instance_variable_defined?("@b")   #=> true
fred.instance_variable_defined?("@c")   #=> false

Removes the named instance variable from obj, returning that variable’s value. String arguments are converted to symbols.

class Dummy
  attr_reader :var
  def initialize
    @var = 99
  end
  def remove
    remove_instance_variable(:@var)
  end
end
d = Dummy.new
d.var      #=> 99
d.remove   #=> 99
d.var      #=> nil

Returns a list of the public instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included.

Returns a list of the protected instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included.

Returns a list of the private instance methods defined in mod. If the optional parameter is false, the methods of any ancestors are not included.

module Mod
  def method1()  end
  private :method1
  def method2()  end
end
Mod.instance_methods           #=> [:method2]
Mod.private_instance_methods   #=> [:method1]

Returns a list of the undefined instance methods defined in mod. The undefined methods of any ancestors are not included.

Similar to instance_method, searches public method only.

Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise.

Returns true for IPv6 multicast node-local scope address. It returns false otherwise.

Returns true for IPv6 multicast link-local scope address. It returns false otherwise.

Returns true for IPv6 multicast site-local scope address. It returns false otherwise.

Returns true for IPv6 multicast organization-local scope address. It returns false otherwise.

Returns true for IPv6 multicast global scope address. It returns false otherwise.

No documentation available

Initialize WIN32OLE object(ActiveX Control) by calling IPersistMemory::InitNew.

Before calling OLE method, some kind of the ActiveX controls created with MFC should be initialized by calling IPersistXXX::InitNew.

If and only if you received the exception “HRESULT error code: 0x8000ffff catastrophic failure”, try this method before invoking any ole_method.

obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control")
obj.ole_activex_initialize
obj.method(...)

Handle BasicObject instances

Returns the value of the local variable symbol.

def foo
  a = 1
  binding.local_variable_get(:a) #=> 1
  binding.local_variable_get(:b) #=> NameError
end

This method is the short version of the following code:

binding.eval("#{symbol}")

Set local variable named symbol as obj.

def foo
  a = 1
  bind = binding
  bind.local_variable_set(:a, 2) # set existing local variable `a'
  bind.local_variable_set(:b, 3) # create new local variable `b'
                                 # `b' exists only in binding

  p bind.local_variable_get(:a)  #=> 2
  p bind.local_variable_get(:b)  #=> 3
  p a                            #=> 2
  p b                            #=> NameError
end

This method behaves similarly to the following code:

binding.eval("#{symbol} = #{obj}")

if obj can be dumped in Ruby code.

Returns true if a local variable symbol exists.

def foo
  a = 1
  binding.local_variable_defined?(:a) #=> true
  binding.local_variable_defined?(:b) #=> false
end

This method is the short version of the following code:

binding.eval("defined?(#{symbol}) == 'local-variable'")
No documentation available
No documentation available
No documentation available
No documentation available
Search took: 2ms  ·  Total Results: 1651