Sha256: d7974f12e3fa686fa8b1a47e1e272f5c3dae5ecfa0b918d88b950c24a2f0d6d5

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

module Kanoko
  module Application
    class Convert
      class Function
        include Enumerable
        extend Forwardable
        def_delegators :@args, :each, :to_a, :to_h

        def initialize(args)
          @args = parse args
        end

        def to_path
          paths = []
          @args.each do |func, arg|
            paths << "/#{func}/#{arg}"
          end
          paths.join
        end

        private

        def parse(args)
          hash = {}
          items = args.split('/')
          items.each_slice(2) do |funcname, arg|
            if funcname.match(/\./)
              break
            else
              hash[funcname.to_sym] = arg.to_s
            end
          end
          hash
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kanoko-0.1.0 lib/kanoko/application/convert/function.rb