Class: DBF::ColumnType::Memo

Inherits:
Base
  • Object
show all
Defined in:
lib/dbf/column_type.rb

Instance Attribute Summary

Attributes inherited from Base

#decimal, #encoding

Instance Method Summary collapse

Methods inherited from Base

#blank_value, #initialize, #skip_blank?

Constructor Details

This class inherits a constructor from DBF::ColumnType::Base

Instance Method Details

#decode(raw, &memo_handler) ⇒ Object



122
123
124
125
# File 'lib/dbf/column_type.rb', line 122

def decode(raw, &memo_handler)
  memo_content = memo_handler.call(raw)
  memo_content ? type_cast(memo_content) : nil
end

#type_cast(value) ⇒ Object

Parameters:



128
129
130
131
132
# File 'lib/dbf/column_type.rb', line 128

def type_cast(value)
  return value unless encoding && value

  value.dup.force_encoding(encoding).encode(Encoding.default_external, undef: :replace, invalid: :replace)
end