Class: Scrubyt::Result
- Inherits:
-
Object
- Object
- Scrubyt::Result
- Defined in:
- lib/scrubyt/output/result.rb
Overview
Represents the results of a pattern
Instance Attribute Summary collapse
-
#childmap ⇒ Object
readonly
Returns the value of attribute childmap.
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
Instance Method Summary collapse
- #add_result(source, result) ⇒ Object
-
#initialize ⇒ Result
constructor
A new instance of Result.
- #lookup(last_result) ⇒ Object
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
8 9 10 |
# File 'lib/scrubyt/output/result.rb', line 8 def initialize @childmap ||= [] end |
Instance Attribute Details
#childmap ⇒ Object (readonly)
Returns the value of attribute childmap.
6 7 8 |
# File 'lib/scrubyt/output/result.rb', line 6 def childmap @childmap end |
#instances ⇒ Object (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 |