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.


73
74
75
# File 'lib/epub/searcher/result.rb', line 73

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

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index


71
72
73
# File 'lib/epub/searcher/result.rb', line 71

def index
  @index
end

#infoObject (readonly)

Returns the value of attribute info


71
72
73
# File 'lib/epub/searcher/result.rb', line 71

def info
  @info
end

#typeObject (readonly)

Returns the value of attribute type


71
72
73
# File 'lib/epub/searcher/result.rb', line 71

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object


77
78
79
80
81
# File 'lib/epub/searcher/result.rb', line 77

def ==(other)
  self.type == other.type and
    self.index == other.index and
    self.info == other.info
end

#to_cfi_sObject


83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/epub/searcher/result.rb', line 83

def to_cfi_s
  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