lib/rdf/model/literal/temporal.rb in rdf-3.2.5 vs lib/rdf/model/literal/temporal.rb in rdf-3.2.6
- old
+ new
@@ -126,11 +126,11 @@
##
# Returns the value as a string.
#
# @return [String]
def to_s
- @string || (@object.strftime(self.class.const_get(:FORMAT)).sub('.000', '') + self.tz)
+ @string ||= (@object.strftime(self.class.const_get(:FORMAT)).sub('.000', '') + self.tz)
end
##
# Adjust the timezone.
#
@@ -144,21 +144,21 @@
# @overload adjust_to_timezone!(zone)
# If `zone` is nil, then the timzeone component is removed.
#
# Otherwise, the timezone is set based on the difference between the current timezone offset (if any) and `zone`.
#
- # @param [String] zone (nil) In the form of {ZONE_GRAMMAR}.
+ # @param [DayTimeDuration, String] zone (nil) In the form of {ZONE_GRAMMAR}.
# @return [Temporal] `self`
# @raise [RangeError] if `zone < -14*60` or `zone > 14*60`
# @see https://www.w3.org/TR/xpath-functions/#func-adjust-dateTime-to-timezone
def adjust_to_timezone!(*args)
zone = args.empty? ? '+00:00' : args.first
- if zone.nil?
+ if zone.to_s.empty?
# Remove timezone component
@object = self.class.new(@object.strftime(self.class.const_get(:FORMAT))).object
@zone = nil
else
- md = zone.match(ZONE_GRAMMAR)
+ md = zone.to_s.match(ZONE_GRAMMAR)
raise ArgumentError,
"expected #{zone.inspect} to be a xsd:dayTimeDuration or +/-HH:MM" unless md
# Adjust to zone
si, hr, mi = md[:si], md[:hr], md[:mi]