lib/epub/cfi.rb in epub-parser-0.2.4 vs lib/epub/cfi.rb in epub-parser-0.2.5

- old
+ new

@@ -83,15 +83,15 @@ @steps = original.steps.collect(&:dup) @offset = original.offset.dup if original.offset end def to_s - @string_cache ||= (steps.join + offset.to_s).freeze + @string_cache ||= (steps.join + offset.to_s) end def to_fragment - @fragment_cache ||= "epubcfi(#{self})".freeze + @fragment_cache ||= "epubcfi(#{self})" end def <=>(other) other_steps = other.steps index = 0 @@ -171,15 +171,15 @@ new_range end end def to_s - @string_cache ||= (first.to_fragment + (exclude_end? ? '...' : '..') + last.to_fragment).freeze + @string_cache ||= (first.to_fragment + (exclude_end? ? '...' : '..') + last.to_fragment) end def to_fragment - @fragment_cache ||= "epubcfi(#{@parent},#{@start},#{@end})".freeze + @fragment_cache ||= "epubcfi(#{@parent},#{@start},#{@end})" end end class Step attr_reader :value, :assertion @@ -194,11 +194,11 @@ @value = original.value @assertion = original.assertion.dup if original.assertion end def to_s - @string_cache ||= "/#{value}#{assertion}".freeze # need escape? + @string_cache ||= "/#{value}#{assertion}" # need escape? end def <=>(other) value <=> other.value end @@ -220,18 +220,18 @@ @string_cache = nil end def to_s return @string_cache if @string_cache - @string_cache = '[' - @string_cache << CFI.escape(id) if id + 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)}" + string_cache << ";#{CFI.escape(key)}=#{CFI.escape(value)}" end - @string_cache << ']' - @string_cache.freeze + string_cache << ']' + @string_cache = string_cache end end class TextLocationAssertion attr_reader :preceded, :followed, :parameters @@ -241,19 +241,19 @@ @string_cache = nil end def to_s return @string_cache if @string_cache - @string_cache = '[' - @string_cache << CFI.escape(preceded) if preceded - @string_cache << ',' << CFI.escape(followed) if followed + string_cache = '[' + string_cache << CFI.escape(preceded) if preceded + string_cache << ',' << CFI.escape(followed) if followed parameters.each_pair do |key, values| value = values.join(',') - @string_cache << ";#{CFI.escape(key)}=#{CFI.escape(value)}" + string_cache << ";#{CFI.escape(key)}=#{CFI.escape(value)}" end - @string_cache << ']' - @string_cache.freeze + string_cache << ']' + @string_cache = string_cache end end class CharacterOffset attr_reader :value, :assertion @@ -263,11 +263,11 @@ @value, @assertion = value, assertion @string_cache = nil end def to_s - @string_cache ||= ":#{value}#{assertion}".freeze # need escape? + @string_cache ||= ":#{value}#{assertion}" # need escape? end def <=>(other) value <=> other.value end @@ -279,18 +279,18 @@ 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 + @string_cache = nil end 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.freeze + string_cache = '' + string_cache << "~#{temporal}" if temporal + string_cache << "@#{x}:#{y}" if x or y + @string_cache = string_cache end # @note should split the class to spatial offset and temporal-spatial offset? def <=>(other) return -1 if temporal.nil? and other.temporal