Class: VariableArray

Inherits:
Array show all
Defined in:
lib/variable_array.rb

Instance Method Summary collapse

Methods inherited from Array

#matcher, #pathify_strings

Instance Method Details

#==(other) ⇒ Object Also known as: eql?


2
3
4
5
6
7
8
9
# File 'lib/variable_array.rb', line 2

def ==(other)
  if other.is_a?(Array)
    comp = self[1..(self.length - 1)]
    return comp.first == other.first
  else
    super
  end
end

#collect(&block) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/variable_array.rb', line 10

def collect(&block)
  self.class.new.tap do |ret|
    self.each_with_index do |el, i|
      ret[i] = block.call(el)
    end
  end
end