Class | Instance
In: | lib/core/facets/instance.rb
Parent: | Object

# Instance Class

      class Friend
        attr_accessor :name, :age, :phone
        def initialize(name, age, phone)
          @name, @age, @phone = name, age, phone
        end
      end

      f1 = Friend.new("John", 30, "555-1212")
      f1.instance

      f1.instance.update({:name=>'Jerry'})
      f1.instance

### Methods

<< [] []= assign each eval instance_delegate keys names new to_h to_hash update values variables

### Included Modules

Enumerable

### Public Class methods

new(delegate)

### Public Instance methods

<<(pair)
[](name)
[]=(name, value)
assign(hash)

Alias for update

each() {|name[1..-1].to_sym, @delegate.instance_variable_get(name)| ...}
eval(*a,&b)

Instance evaluation.

instance_delegate()
keys()

Instance vairable names as symbols.

names()

Instance variable names as strings.

to_h(at=false)

Return instance variables with values as a hash.

      class X
        def initialize(a,b)
          @a, @b = a, b
        end
      end

      x = X.new(1,2)

      x.instance.to_h  #=> { :a=>1, :b=>2 }

to_hash(at=false)

Alias for to_h

update(hash)

Set instance variables given a `hash`.

      instance.update('@a'=>1, '@b'=>2)
      @a   #=> 1
      @b   #=> 2

Also, +@+ sign is not neccessary.

      instance.update(:a=>1, :b=>2)
      @a   #=> 1
      @b   #=> 2

values()

Instance variable values.

variables()

Same as instance_variables.

[Validate]