Sha256: fcf0cd555cf9dce78a2a16ae37e9a4c04fac222335afee1d9037751710202e5e

Contents?: true

Size: 496 Bytes

Versions: 1

Compression:

Stored size: 496 Bytes

Contents

require_relative '../constants'

module Squib
  module Args
    # :nodoc:
    # @api private
    module UnitConversion

      # :nodoc:
      # @api private
      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

1 entries across 1 versions & 1 rubygems

Version Path
squib-0.10.0 lib/squib/args/unit_conversion.rb