Class: EPUB::Searcher::Result
- Inherits:
-
Object
- Object
- EPUB::Searcher::Result
- Defined in:
- lib/epub/searcher/result.rb
Defined Under Namespace
Classes: Step
Instance Attribute Summary collapse
-
#end_steps ⇒ Object
readonly
Returns the value of attribute end_steps.
-
#parent_steps ⇒ Object
readonly
Returns the value of attribute parent_steps.
-
#start_steps ⇒ Object
readonly
Returns the value of attribute start_steps.
Class Method Summary collapse
-
.aggregate_step_intersection(steps1, steps2) ⇒ Array<Array<Array>>
Three arrays: 1.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(parent_steps, start_steps, end_steps) ⇒ Result
constructor
A new instance of Result.
- #to_cfi ⇒ Object
Constructor Details
#initialize(parent_steps, start_steps, end_steps) ⇒ Result
Returns a new instance of Result.
42 43 44 |
# File 'lib/epub/searcher/result.rb', line 42 def initialize(parent_steps, start_steps, end_steps) @parent_steps, @start_steps, @end_steps = parent_steps, start_steps, end_steps end |
Instance Attribute Details
#end_steps ⇒ Object (readonly)
Returns the value of attribute end_steps.
37 38 39 |
# File 'lib/epub/searcher/result.rb', line 37 def end_steps @end_steps end |
#parent_steps ⇒ Object (readonly)
Returns the value of attribute parent_steps.
37 38 39 |
# File 'lib/epub/searcher/result.rb', line 37 def parent_steps @parent_steps end |
#start_steps ⇒ Object (readonly)
Returns the value of attribute start_steps.
37 38 39 |
# File 'lib/epub/searcher/result.rb', line 37 def start_steps @start_steps end |
Class Method Details
.aggregate_step_intersection(steps1, steps2) ⇒ Array<Array<Array>>
Returns Three arrays:
-
“intersection” of
steps1
andsteps2
. “intersection” here is not the term of mathmatics -
remaining steps of
steps1
-
remaining steps of
steps2
.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/epub/searcher/result.rb', line 18 def aggregate_step_intersection(steps1, steps2) intersection = [] steps1_remaining = [] steps2_remaining = [] broken = false steps1.zip steps2 do |step1, step2| broken = true unless step1 && step2 && step1 == step2 if broken steps1_remaining << step1 unless step1.nil? steps2_remaining << step2 unless step2.nil? else intersection << step1 end end [intersection, steps1_remaining, steps2_remaining] end |
Instance Method Details
#==(other) ⇒ Object
53 54 55 56 |
# File 'lib/epub/searcher/result.rb', line 53 def ==(other) [@parent_steps + @start_steps.to_a] == [other.parent_steps + other.start_steps.to_a] and [@parent_steps + @end_steps.to_a] == [other.parent_steps + other.end_steps.to_a] end |
#to_cfi ⇒ Object
46 47 48 49 50 51 |
# File 'lib/epub/searcher/result.rb', line 46 def to_cfi str = [@parent_steps, @start_steps, @end_steps].collect {|steps| steps ? steps.collect(&:to_cfi).join : nil }.compact.join(',') EPUB::CFI(str) end |