Class: Cpr::AlphanumericField

Inherits:
Field
  • Object
show all
Defined in:
lib/cpr/alphanumeric_field.rb

Instance Attribute Summary

Attributes inherited from Field

#default, #name, #range

Instance Method Summary collapse

Methods inherited from Field

create_type, #fill, #initialize, #length, #pattern, #read, #write

Constructor Details

This class inherits a constructor from Cpr::Field

Instance Method Details

#cast_for_read(val) ⇒ Object



4
5
6
# File 'lib/cpr/alphanumeric_field.rb', line 4

def cast_for_read(val)
  val.strip.encode("utf-8")
end

#cast_for_write(val) ⇒ Object



8
9
10
# File 'lib/cpr/alphanumeric_field.rb', line 8

def cast_for_write(val)
  val.ljust(length)
end