Class: EPUB::CFI::Step

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) ⇒ Step

Returns a new instance of Step.



188
189
190
191
# File 'lib/epub/cfi.rb', line 188

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

Instance Attribute Details

#assertionObject (readonly)

Returns the value of attribute assertion.



185
186
187
# File 'lib/epub/cfi.rb', line 185

def assertion
  @assertion
end

#valueObject (readonly) Also known as: step

Returns the value of attribute value.



185
186
187
# File 'lib/epub/cfi.rb', line 185

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



202
203
204
# File 'lib/epub/cfi.rb', line 202

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

#character_data?Boolean

Returns:

  • (Boolean)


210
211
212
# File 'lib/epub/cfi.rb', line 210

def character_data?
  value.odd?
end

#element?Boolean

Returns:

  • (Boolean)


206
207
208
# File 'lib/epub/cfi.rb', line 206

def element?
  value.even?
end

#initialize_copy(original) ⇒ Object



193
194
195
196
# File 'lib/epub/cfi.rb', line 193

def initialize_copy(original)
  @value = original.value
  @assertion = original.assertion.dup if original.assertion
end

#to_sObject



198
199
200
# File 'lib/epub/cfi.rb', line 198

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