Class: EPUB::CFI::TextLocationAssertion

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(preceded = nil, followed = nil, parameters = {}) ⇒ TextLocationAssertion

Returns a new instance of TextLocationAssertion.


239
240
241
242
# File 'lib/epub/cfi.rb', line 239

def initialize(preceded=nil, followed=nil, parameters={})
  @preceded, @followed, @parameters = preceded, followed, parameters
  @string_cache = nil
end

Instance Attribute Details

#followedObject (readonly)

Returns the value of attribute followed


237
238
239
# File 'lib/epub/cfi.rb', line 237

def followed
  @followed
end

#parametersObject (readonly)

Returns the value of attribute parameters


237
238
239
# File 'lib/epub/cfi.rb', line 237

def parameters
  @parameters
end

#precededObject (readonly)

Returns the value of attribute preceded


237
238
239
# File 'lib/epub/cfi.rb', line 237

def preceded
  @preceded
end

Instance Method Details

#to_sObject


244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/epub/cfi.rb', line 244

def to_s
  return @string_cache if @string_cache
  @string_cache = '['
  @string_cache << CFI.escape(preceded) if preceded
  @string_cache << ',' << CFI.escape(followed) if followed
  parameters.each_pair do |key, values|
    value = values.join(',')
    @string_cache << ";#{CFI.escape(key)}=#{CFI.escape(value)}"
  end
  @string_cache << ']'
  @string_cache.freeze
end