OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/lib/open_project/backlogs/taskboard_card/measurement.rb

31 lines
665 B

require 'prawn/measurement_extensions'
module OpenProject::Backlogs::TaskboardCard
module Measurement
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def to_pts(v)
return if v.nil?
if v =~ /[a-z]{2}$/i
units = v[-2, 2].downcase
v = v[0..-3]
else
units = 'pt'
end
v = "#{v}0" if v =~ /\.$/
return Float(v).mm if units == 'mm'
return Float(v).cm if units == 'cm'
return Float(v).in if units == 'in'
return Float(v).pt if units == 'pt'
raise "Unexpected units '#{units}'"
end
end
end
end