Skip to content

Commit

Permalink
Try casting start and end time into Floats but fall back to actual value
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed May 19, 2016
1 parent f49282e commit 63c683f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/active_annotations/rdf_annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def fragment_value=(value)

def start_time
value = fragment_value.nil? ? nil : fragment_value.object.value.scan(/^t=(.*)$/).flatten.first.split(/,/)[0]
value.nil? ? nil : value.to_f
Float(value)
rescue
value
end

def start_time=(value)
Expand All @@ -151,7 +153,9 @@ def start_time=(value)

def end_time
value = fragment_value.nil? ? nil : fragment_value.object.value.scan(/^t=(.*)$/).flatten.first.split(/,/)[1]
value.nil? ? nil : value.to_f
Float(value)
rescue
value
end

def end_time=(value)
Expand Down

0 comments on commit 63c683f

Please sign in to comment.