Class: EPUB::CFI::IDAssertion

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, parameters = {}) ⇒ IDAssertion

Returns a new instance of IDAssertion.


218
219
220
221
# File 'lib/epub/cfi.rb', line 218

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


216
217
218
# File 'lib/epub/cfi.rb', line 216

def id
  @id
end

#parametersObject (readonly)

Returns the value of attribute parameters


216
217
218
# File 'lib/epub/cfi.rb', line 216

def parameters
  @parameters
end

Instance Method Details

#to_sObject


223
224
225
226
227
228
229
230
231
232
233
# File 'lib/epub/cfi.rb', line 223

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