Sha256: f711b3393f9ad7e6040850d7a45ba35848768d3438c4749d75f5f220ddc818f7

Contents?: true

Size: 412 Bytes

Versions: 2

Compression:

Stored size: 412 Bytes

Contents

require 'squib/constants'

module Squib
  module Args
    module UnitConversion

      module_function
      def parse(arg, dpi=300)
        case arg.to_s.rstrip
        when /in$/ #ends with "in"
          arg.rstrip[0..-2].to_f * dpi
        when /cm$/ #ends with "cm"
          arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
        else
          arg
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
squib-0.4.0 lib/squib/args/unit_conversion.rb
squib-0.3.0 lib/squib/args/unit_conversion.rb