Sha256: 7ec76fcfd2d6244db313d31472962d6226157e86449ed4b7c2d42b350bf6e256

Contents?: true

Size: 572 Bytes

Versions: 3

Compression:

Stored size: 572 Bytes

Contents

require 'iconv' unless "older_ruby?".respond_to?(:force_encoding)

class PTT::DataRow

  attr_accessor :num, :record, :state

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

  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

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

  def to_s_attribute
    @n.to_s
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ptt-1.0.3 lib/ptt/data_row.rb
ptt-1.0.2 lib/ptt/data_row.rb
ptt-1.0.1 lib/ptt/data_row.rb