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.



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

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

Instance Attribute Details

#assertionObject (readonly)

Returns the value of attribute assertion.



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

def assertion
  @assertion
end

#valueObject (readonly) Also known as: offset

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



271
272
273
# File 'lib/epub/cfi.rb', line 271

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

#to_sObject



267
268
269
# File 'lib/epub/cfi.rb', line 267

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