Class: EPUB::CFI::CharacterOffset

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, assertion = nil) ⇒ CharacterOffset

Returns a new instance of CharacterOffset.



255
256
257
258
# File 'lib/epub/cfi.rb', line 255

def initialize(value, assertion=nil)
  @value, @assertion = value, assertion
  @string_cache = nil
end

Instance Attribute Details

#assertionObject (readonly)

Returns the value of attribute assertion.



252
253
254
# File 'lib/epub/cfi.rb', line 252

def assertion
  @assertion
end

#valueObject (readonly) Also known as: offset

Returns the value of attribute value.



252
253
254
# File 'lib/epub/cfi.rb', line 252

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



264
265
266
# File 'lib/epub/cfi.rb', line 264

def <=>(other)
  value <=> other.value
end

#to_sObject



260
261
262
# File 'lib/epub/cfi.rb', line 260

def to_s
  @string_cache ||= ":#{value}#{assertion}" # need escape?
end