Class: Lhm::Intersection

Inherits:
Object
  • Object
show all
Defined in:
lib/lhm/intersection.rb

Overview

Determine and format columns common to origin and destination.

Instance Method Summary collapse

Constructor Details

#initialize(origin, destination) ⇒ Intersection

Returns a new instance of Intersection.



7
8
9
10
# File 'lib/lhm/intersection.rb', line 7

def initialize(origin, destination)
  @origin = origin
  @destination = destination
end

Instance Method Details

#commonObject



12
13
14
# File 'lib/lhm/intersection.rb', line 12

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

#escapedObject



16
17
18
# File 'lib/lhm/intersection.rb', line 16

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

#joinedObject



20
21
22
# File 'lib/lhm/intersection.rb', line 20

def joined
  escaped.join(", ")
end

#typed(type) ⇒ Object



24
25
26
# File 'lib/lhm/intersection.rb', line 24

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