Class: Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::DateVal
Overview
Defined Under Namespace
Classes: Empty, Improper, Invalid, Proper
Instance Attribute Summary
#position, #usage
Instance Method Summary
collapse
#allowed?, #component?, #copy, #id?, #initialize, #leaf?, #numeric?, #simple?, #string?, #time?, #to_x12
#element?, #size
#blank?, #characters, #component?, #composite?, #definition, #element?, #empty?, #functional_group?, #interchange?, #invalid?, #loop?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?
Methods included from Color
ansi, #ansi
Methods included from Inspect
#inspect
Class Method Details
509
510
511
|
# File 'lib/stupidedi/versions/functional_groups/003010/element_types/date_val.rb', line 509
def empty(usage, position)
self::Empty.new(usage, position)
end
|
.value(object, usage, position) ⇒ DateVal
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
# File 'lib/stupidedi/versions/functional_groups/003010/element_types/date_val.rb', line 514
def value(object, usage, position)
if object.blank?
self::Empty.new(usage, position)
elsif object.is_a?(String) or object.is_a?(StringVal)
string = object.to_s
if string.length < 6
self::Invalid.new(object, usage, position)
else
day = string.slice(-2, 2).to_i
month = string.slice(-4, 2).to_i
year = string.slice( 0..-5)
if year.length < 4
self::Improper.new(year.to_i, month, day, usage, position)
else
date = date(year, month, day)
self::Proper.new(date, usage, position)
end
end
elsif object.respond_to?(:year) and object.respond_to?(:month) and object.respond_to?(:day)
date = date(object.year, object.month, object.day)
self::Proper.new(date, usage, position)
elsif object.is_a?(DateVal::Improper)
self::Improper.new(object.year, object.month, object.day, usage, position)
else
self::Invalid.new(object, usage, position)
end
rescue Exceptions::InvalidElementError
self::Invalid.new(object, usage, position)
end
|
Instance Method Details
#date? ⇒ Boolean
40
41
42
|
# File 'lib/stupidedi/versions/functional_groups/003010/element_types/date_val.rb', line 40
def date?
true
end
|
#too_long? ⇒ Boolean
44
45
46
|
# File 'lib/stupidedi/versions/functional_groups/003010/element_types/date_val.rb', line 44
def too_long?
false
end
|
#too_short? ⇒ Boolean
48
49
50
|
# File 'lib/stupidedi/versions/functional_groups/003010/element_types/date_val.rb', line 48
def too_short?
false
end
|