Class: Gdt::GdtField
- Inherits:
-
Struct
- Object
- Struct
- Gdt::GdtField
- Defined in:
- lib/gdt/field_handling.rb
Constant Summary collapse
- TYPES =
{ :num => lambda { |v| v.to_i }, :alnum => lambda { |v| ::Iconv.new("UTF-8","CP850").iconv(v) }, :datum => lambda { |v| ::Date.new(*v.scan(/(..)(..)(....)/)[0].map {|x| x.to_i }.reverse) rescue nil } }
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#length ⇒ Object
Returns the value of attribute length.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rules ⇒ Object
Returns the value of attribute rules.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
6 7 8 |
# File 'lib/gdt/field_handling.rb', line 6 def description @description end |
#length ⇒ Object
Returns the value of attribute length
6 7 8 |
# File 'lib/gdt/field_handling.rb', line 6 def length @length end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/gdt/field_handling.rb', line 6 def name @name end |
#rules ⇒ Object
Returns the value of attribute rules
6 7 8 |
# File 'lib/gdt/field_handling.rb', line 6 def rules @rules end |
#type ⇒ Object
Returns the value of attribute type
6 7 8 |
# File 'lib/gdt/field_handling.rb', line 6 def type @type end |
Instance Method Details
#verify_and_convert(value) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gdt/field_handling.rb', line 29 def verify_and_convert(value) # check length # if @length = "the field #{name.inspect} does not have the correct length, expected (#{@length.inspect})" # ignore length checks for now # raise ArgumentError, message unless @length.include?(value.length) end TYPES[self.type].call(value) end |