Class: PT::DataRow

Inherits:
Object
  • Object
show all
Defined in:
lib/pt/data_row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orig, dataset) ⇒ DataRow

Returns a new instance of DataRow.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pt/data_row.rb', line 8

def initialize(orig, dataset)
  @record = orig
  @num = dataset.index(orig) + 1
  if defined? orig.current_state
    @state = orig.current_state
  end

  if defined? orig.owners
    @owners = orig.owners.map(&:initials).join(',')
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



20
21
22
23
# File 'lib/pt/data_row.rb', line 20

def method_missing(method)
  str = @record.send(method).to_s
  str.respond_to?(:force_encoding) ? str.force_encoding('utf-8') : Iconv.iconv('UTF-8', 'UTF-8', str)
end

Instance Attribute Details

#numObject

Returns the value of attribute num.



6
7
8
# File 'lib/pt/data_row.rb', line 6

def num
  @num
end

#ownersObject

Returns the value of attribute owners.



6
7
8
# File 'lib/pt/data_row.rb', line 6

def owners
  @owners
end

#recordObject

Returns the value of attribute record.



6
7
8
# File 'lib/pt/data_row.rb', line 6

def record
  @record
end

#stateObject

Returns the value of attribute state.



6
7
8
# File 'lib/pt/data_row.rb', line 6

def state
  @state
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/pt/data_row.rb', line 25

def to_s
  @record.send(self.to_s_attribute)
end

#to_s_attributeObject



29
30
31
# File 'lib/pt/data_row.rb', line 29

def to_s_attribute
  @n.to_s
end