class EPUB::Searcher::Result::Step

Attributes

index[R]
info[R]
type[R]

Public Class Methods

new(type, index, info={}) click to toggle source
# File lib/epub/searcher/result.rb, line 61
def initialize(type, index, info={})
  @type, @index, @info = type, index, info
end

Public Instance Methods

==(other) click to toggle source
# File lib/epub/searcher/result.rb, line 65
def ==(other)
  self.type == other.type and
    self.index == other.index and
    self.info == other.info
end
to_cfi() click to toggle source
# File lib/epub/searcher/result.rb, line 71
def to_cfi
  case type
  when :element
    '/%d%s' % [(index + 1) * 2, id_assertion]
  when :text
    '/%d' % [(index + 1)]
  when :character
    ':%d' % [index]
  when :itemref
    '/%d%s!' % [(index + 1) * 2, id_assertion]
  end
end

Private Instance Methods

id_assertion() click to toggle source
# File lib/epub/searcher/result.rb, line 86
def id_assertion
  info[:id] ? "[#{info[:id]}]" : nil
end