Class: Scrubyt::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/scrubyt/output/result.rb

Overview

Represents the results of a pattern

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



8
9
10
# File 'lib/scrubyt/output/result.rb', line 8

def initialize
  @childmap ||= []
end

Instance Attribute Details

#childmapObject (readonly)

Returns the value of attribute childmap.



6
7
8
# File 'lib/scrubyt/output/result.rb', line 6

def childmap
  @childmap
end

#instancesObject (readonly)

Returns the value of attribute instances.



6
7
8
# File 'lib/scrubyt/output/result.rb', line 6

def instances
  @instances
end

Instance Method Details

#add_result(source, result) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/scrubyt/output/result.rb', line 12

def add_result(source, result)
  @childmap.each do |hash|
    if hash.keys[0] == source
      hash[source] << result if !hash[source].include? result
      return
    end
  end
  @childmap << {source => [result]}
end

#lookup(last_result) ⇒ Object



22
23
24
25
26
27
# File 'lib/scrubyt/output/result.rb', line 22

def lookup(last_result)
  @childmap.each do |hashes|
    hashes.each { |key, value| return value if (key == last_result) }
  end
  nil
end