Sha256: aa71ccb9e5664d9f1ea5868299f6715b6ac3aab75299cbe603407dba3cf66f14

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

# encoding: utf-8

module Piglet
  module Inout
    class Load # :nodoc:
      include Piglet::Relation::Relation
      include StorageTypes
    
      def initialize(path, interpreter, options={})
        options ||= {}
        @path, @interpreter, @using, @schema = path, interpreter, options[:using], options[:schema]
      end
    
      def schema
        Piglet::Schema::Tuple.parse(@schema) if @schema
      end
    
      def to_s
        str  = "LOAD '#{@path}'"
        str << " USING #{resolve_load_store_function(@using)}" if @using
        str << " AS (#{schema_string})" if @schema
        str
      end
    
    private
        
      def schema_string
        @schema.map do |field|
          if field.is_a?(Enumerable)
            field.map { |f| f.to_s }.join(':')
          else
            field.to_s
          end
        end.join(', ')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
piglet-0.3.0 lib/piglet/inout/load.rb