Class: Array

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

Instance Method Summary collapse

Instance Method Details

#where(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cucumber_monitor/array.rb', line 4

def where(options={})
  result = []
  self.each do |item|
    if item.respond_to?(:name) && item.name.include?(options[:name])
      result << item
    end

    if item.respond_to?(:description) && !item.description.nil? && !options[:description].nil? && item.description.include?(options[:description])
      result << item
    end

    if item.respond_to?(:id) && item.id == options[:id]
      result << item
    end
  end

  result.uniq!

  if result.size == 1
    result.first
  else
    result
  end
end