Class | X12::Field |
In: |
lib/X12/Field.rb
|
Parent: | Object |
$Id: Field.rb 35 2008-11-13 18:33:44Z ikk $
Class to represent a segment field. Please note, it‘s not a descendant of Base.
content | [W] | |
max_length | [R] | |
min_length | [R] | |
name | [R] | |
required | [R] | |
type | [R] | |
validation | [R] |
Create a new field with given parameters
# File lib/X12/Field.rb, line 35 35: def initialize(name, type, required, min_length, max_length, validation) 36: @name = name 37: @type = type 38: @required = required == 'R' ? true : false 39: @min_length = min_length.to_i 40: @max_length = max_length.to_i 41: @validation = validation 42: @content = nil 43: end
Check if it‘s been set yet
# File lib/X12/Field.rb, line 61 61: def has_content? 62: !@content.nil? 63: end
Returns printable string with field‘s content
# File lib/X12/Field.rb, line 46 46: def inspect 47: "Field #{name}|#{type}|#{required}|#{min_length}-#{max_length}|#{validation} <#{@content}>" 48: end
# File lib/X12/Field.rb, line 55 55: def render 56: # FIXME - this is for debug only 57: @content || '' 58: end