Class: EPUB::Searcher::Result::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/epub/searcher/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, index, info = {}) ⇒ Step

Returns a new instance of Step.



61
62
63
# File 'lib/epub/searcher/result.rb', line 61

def initialize(type, index, info={})
  @type, @index, @info = type, index, info
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



59
60
61
# File 'lib/epub/searcher/result.rb', line 59

def index
  @index
end

#infoObject (readonly)

Returns the value of attribute info.



59
60
61
# File 'lib/epub/searcher/result.rb', line 59

def info
  @info
end

#typeObject (readonly)

Returns the value of attribute type.



59
60
61
# File 'lib/epub/searcher/result.rb', line 59

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



65
66
67
68
69
# 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_cfiObject



71
72
73
74
75
76
77
78
79
80
81
82
# 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