Class: DataShift::InboundData::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/datashift/inbound_data/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, index = -1)) ⇒ Column

Returns a new instance of Column.



17
18
19
20
21
22
23
24
# File 'lib/datashift/inbound_data/column.rb', line 17

def initialize(source, index = -1)

  @header = DataShift::Header.new(source: source)

  @index = index
  @lookup_list = []
  @data = []
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



15
16
17
# File 'lib/datashift/inbound_data/column.rb', line 15

def data
  @data
end

#headerObject

Returns the value of attribute header.



15
16
17
# File 'lib/datashift/inbound_data/column.rb', line 15

def header
  @header
end

#indexObject

Returns the value of attribute index.



15
16
17
# File 'lib/datashift/inbound_data/column.rb', line 15

def index
  @index
end

#lookup_listObject Also known as: lookups

Returns the value of attribute lookup_list.



15
16
17
# File 'lib/datashift/inbound_data/column.rb', line 15

def lookup_list
  @lookup_list
end

Instance Method Details

#add_lookup(klass, field, where_value) ⇒ Object



30
31
32
# File 'lib/datashift/inbound_data/column.rb', line 30

def add_lookup( klass, field, where_value )
  @lookup_list.unshift( LookupSupport.new(klass, field, where_value) )
end

#find_by_operatorObject



34
35
36
# File 'lib/datashift/inbound_data/column.rb', line 34

def find_by_operator
  lookup_list.first ? lookup_list.first.field : ''
end

#find_by_valueObject



38
39
40
# File 'lib/datashift/inbound_data/column.rb', line 38

def find_by_value
  lookup_list.first ? lookup_list.first.value : ''
end