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



181
182
183
184
# File 'lib/epub/cfi.rb', line 181

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

Instance Attribute Details

#assertionObject (readonly)

Returns the value of attribute assertion.



178
179
180
# File 'lib/epub/cfi.rb', line 178

def assertion
  @assertion
end

#valueObject (readonly) Also known as: step

Returns the value of attribute value.



178
179
180
# File 'lib/epub/cfi.rb', line 178

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#character_data?Boolean



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

def character_data?
  value.odd?
end

#element?Boolean



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

def element?
  value.even?
end

#initialize_copy(original) ⇒ Object



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

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

#to_sObject



191
192
193
# File 'lib/epub/cfi.rb', line 191

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