Class: Rigrate::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/rigrate/interface/row.rb

Overview

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = [], status = RowStatus::ORIGIN) ⇒ Row

Returns a new instance of Row.



20
21
22
23
# File 'lib/rigrate/interface/row.rb', line 20

def initialize(data = [], status = RowStatus::ORIGIN)
  self.data = data
  self.status = status
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



16
17
18
# File 'lib/rigrate/interface/row.rb', line 16

def data
  @data
end

#fieldsObject

Returns the value of attribute fields.



18
19
20
# File 'lib/rigrate/interface/row.rb', line 18

def fields
  @fields
end

#statusObject

Returns the value of attribute status.



17
18
19
# File 'lib/rigrate/interface/row.rb', line 17

def status
  @status
end

Instance Method Details

#+(t_row) ⇒ Object

why need in this way? TODO need rework



33
34
35
36
37
38
# File 'lib/rigrate/interface/row.rb', line 33

def +(t_row)
  t_row.data.each { |item| @data << item }
  @status = RowStatus::UPDATED

  self
end

#<<(item) ⇒ Object



63
64
65
66
67
# File 'lib/rigrate/interface/row.rb', line 63

def <<(item)
  @data << item

  self
end

#==(t_row) ⇒ Object



40
41
42
# File 'lib/rigrate/interface/row.rb', line 40

def ==(t_row)
  @data == t_row.data && @status == t_row.status
end

#[](idx) ⇒ Object



50
51
52
# File 'lib/rigrate/interface/row.rb', line 50

def [](idx)
  @data[idx]
end

#[]=(idx, val, status_force = true) ⇒ Object



54
55
56
57
# File 'lib/rigrate/interface/row.rb', line 54

def []=(idx, val, status_force = true)
  @data[idx] = val
  @status = RowStatus::UPDATED if status_force
end

#fill_with_nil(num) ⇒ Object



44
45
46
47
48
# File 'lib/rigrate/interface/row.rb', line 44

def fill_with_nil(num)
  @data += Array.new(num)

  self
end

#sizeObject



59
60
61
# File 'lib/rigrate/interface/row.rb', line 59

def size
 @data.size
end

#values(*idxes) ⇒ Object



25
26
27
28
29
# File 'lib/rigrate/interface/row.rb', line 25

def values(*idxes)
  idxes.map do |idx|
    self[idx]
  end
end