Class: EPUB::CFI::TemporalSpatialOffset
- Inherits:
-
Object
- Object
- EPUB::CFI::TemporalSpatialOffset
- Defined in:
- lib/epub/cfi.rb
Instance Attribute Summary collapse
-
#assertion ⇒ Object
readonly
Returns the value of attribute assertion.
-
#temporal ⇒ Object
readonly
Returns the value of attribute temporal.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(temporal = nil, x = nil, y = nil, assertion = nil) ⇒ TemporalSpatialOffset
constructor
A new instance of TemporalSpatialOffset.
- #to_s ⇒ Object
Constructor Details
#initialize(temporal = nil, x = nil, y = nil, assertion = nil) ⇒ TemporalSpatialOffset
Returns a new instance of TemporalSpatialOffset.
279 280 281 282 283 284 285 |
# 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 #{self.class} but cannot know how to handle with it: #{assertion}" if assertion @temporal, @x, @y, @assertion = temporal, x, y, assertion @string_cache = nil end |
Instance Attribute Details
#assertion ⇒ Object (readonly)
Returns the value of attribute assertion.
277 278 279 |
# File 'lib/epub/cfi.rb', line 277 def assertion @assertion end |
#temporal ⇒ Object (readonly)
Returns the value of attribute temporal.
277 278 279 |
# File 'lib/epub/cfi.rb', line 277 def temporal @temporal end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
277 278 279 |
# File 'lib/epub/cfi.rb', line 277 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
277 278 279 |
# File 'lib/epub/cfi.rb', line 277 def y @y end |
Instance Method Details
#<=>(other) ⇒ Object
Note:
should split the class to spatial offset and temporal-spatial offset?
296 297 298 299 300 301 302 303 304 305 306 307 308 |
# 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 ⇒ Object
287 288 289 290 291 292 293 |
# File 'lib/epub/cfi.rb', line 287 def to_s return @string_cache if @string_cache # @type ivar @string_cache: String string_cache = '' string_cache << "~#{temporal}" if temporal string_cache << "@#{x}:#{y}" if x or y @string_cache = string_cache end |