Sha256: 2acbc53d3488243d16b4839a7383c65f7db8f0e09cc1590ceab6bcbeef0a92c3

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

require 'pathname'

module Komic
  class Generator
    module Helpers
      def self.parse_size(size)
        width_range, height_range = size.split('x')
        width, height = [width_range, height_range].map do |range|
          unless range.nil?
            min, max = range.split('-')
            r = range.to_i
            unless max.nil?
              r = Random.rand(min.to_i...max.to_i)
            end
            r
          end
        end
        return { width: width, height: height }
      end

      def self.get_relativepath_as(path, root)
        File.join('./',
          Pathname.new(path).relative_path_from(
            Pathname.new(root)
          ))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
komic-cli-0.1.0 lib/komic/generator/helpers.rb