class EPUB::CFI::TemporalSpatialOffset
Attributes
assertion[R]
temporal[R]
x[R]
y[R]
Public Class Methods
new(temporal=nil, x=nil, y=nil, assertion=nil)
click to toggle source
# File lib/epub/cfi.rb, line 279 def initialize(temporal=nil, x=nil, y=nil, assertion=nil) raise RangeError, "dimension must be in 0..100 but passed #{x}" unless (0.0..100.0).cover?(x) if x raise RangeError, "dimension must be in 0..100 but passed #{y}" unless (0.0..100.0).cover?(y) if y warn "Assertion is passed to #{__class__} but cannot know how to handle with it: #{assertion}" if assertion @temporal, @x, @y, @assertion = temporal, x, y, assertion @string_cache = nil end
Public Instance Methods
<=>(other)
click to toggle source
@note should split the class to spatial offset and temporal-spatial offset?
# File lib/epub/cfi.rb, line 296 def <=>(other) return -1 if temporal.nil? and other.temporal return 1 if temporal and other.temporal.nil? cmp = temporal <=> other.temporal return cmp unless cmp == 0 return -1 if y.nil? and other.y return 1 if y and other.y.nil? cmp = y <=> other.y return cmp unless cmp == 0 return -1 if x.nil? and other.x return 1 if x and other.x.nil? cmp = x <=> other.x end
to_s()
click to toggle source
# File lib/epub/cfi.rb, line 287 def to_s return @string_cache if @string_cache string_cache = '' string_cache << "~#{temporal}" if temporal string_cache << "@#{x}:#{y}" if x or y @string_cache = string_cache end