Class InstanceVariables
In: lib/core/facets/kernel/instance_variables.rb
Parent: Object

Methods

<<   []   []=   each   instance_delegate   keys   names   new   to_hash   update   values  

Included Modules

Enumerable

Public Class methods

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 14
  def initialize(delegate)
    @delegate = delegate
  end

Public Instance methods

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 46
  def <<(pair)
    name, value = *pair
    name = atize(name)
    @delegate.instance_varaible_set(name, value)
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 36
  def [](name)
    name = atize(name)
    @delegate.instance_variable_get(name)
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 41
  def []=(name, value)
    name = atize(name)
    @delegate.instance_varaible_set(name,value)
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 22
  def each
    @delegate.instance_variables.each do |name|
      yield(name[1..-1].to_sym, @delegate.instance_variable_get(name))
    end
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 18
  def instance_delegate
    @delegate
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 58
  def keys
    @delegate.instance_variables.collect do |name|
      name[1..-1].to_sym
    end
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 64
  def names
    @delegate.instance_variables.collect do |name|
      name[1..-1]
    end
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 28
  def to_hash
    h = {}
    each do |name, value|
      h[name] = value
    end
    h
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 52
  def update(hash)
    hash.each do |pair|
      self << pair
    end
  end

[Source]

# File lib/core/facets/kernel/instance_variables.rb, line 70
  def values
    @delegate.instance_variables.collect do |name|
      @delegate.instance_variable_get(name)
    end
  end

[Validate]