Sha256: 45a9e267cf274090329ee4b0c6e334cad22c53ccbab78a2ce023bbbd39df244b

Contents?: true

Size: 729 Bytes

Versions: 4

Compression:

Stored size: 729 Bytes

Contents

# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt

module Lhm
  #  Determine and format columns common to origin and destination.
  class Intersection
    def initialize(origin, destination)
      @origin = origin
      @destination = destination
    end

    def common
      (@origin.columns.keys & @destination.columns.keys).sort
    end

    def escaped
      common.map { |name| tick(name)  }
    end

    def joined
      escaped.join(", ")
    end

    def typed(type)
      common.map { |name| qualified(name, type)  }.join(", ")
    end

  private

    def qualified(name, type)
      "#{ type }.`#{ name }`"
    end

    def tick(name)
      "`#{ name }`"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lhm-2.1.0 lib/lhm/intersection.rb
lhm-2.0.0 lib/lhm/intersection.rb
lhm-1.3.0 lib/lhm/intersection.rb
lhm-1.2.0 lib/lhm/intersection.rb