Class: SlappingArray

Inherits:
Object
  • Object
show all
Defined in:
lib/reach.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(retract) ⇒ SlappingArray

Returns a new instance of SlappingArray.



76
77
78
# File 'lib/reach.rb', line 76

def initialize(retract)
  @retract = retract
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Try to pass the method to each of the array members



81
82
83
84
85
86
# File 'lib/reach.rb', line 81

def method_missing(method, *args, &block)
  @retract = @retract.collect do |o|
    o.send(method, *args, &block)
  end
  return self
end

Instance Attribute Details

#retractObject

The array that this reaching array is extending. This might be a real Array, or a ReachingArray



74
75
76
# File 'lib/reach.rb', line 74

def retract
  @retract
end

Instance Method Details

#==(another) ⇒ Object

Equality test - equality of the underlying retract arrays is all that matter



90
91
92
# File 'lib/reach.rb', line 90

def ==(another)
  @retract <=> another.retract
end

#reachObject



98
99
100
# File 'lib/reach.rb', line 98

def reach
  retract.reach
end

#to_sObject



94
95
96
# File 'lib/reach.rb', line 94

def to_s
  @retract.to_s
end