-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kputnam
committed
Sep 28, 2011
1 parent
dae2d78
commit 8a2842b
Showing
6 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Serializing X12 | ||
============== | ||
|
||
Once you have built a parse tree, either by generating one programatically (see | ||
{file:Generating.md Generating}) or parsing serialized input (see | ||
{file:Parsing.md}), you can serialize it back to a string using one of the | ||
classes in [`Stupidedi::Writer`][1]. |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
class Stupidedi | ||
module Editor | ||
|
||
class FiftyTenEd | ||
module N4 | ||
|
||
def critique_n4(n4, acc) | ||
edit(:N4) do | ||
usa_canada = | ||
n4.element(2).select(&:present?).defined? || | ||
n4.element(4).select(&:blank?).defined? || | ||
n4.element(4).select{|e| e.node == "US" }.defined? || | ||
n4.element(7).select(&:blank?).defined? | ||
|
||
# State or Province Code | ||
n4.element(2).tap do |e| | ||
if usa_canada | ||
if e.node.blank? and e.node.situational? | ||
# Required | ||
end | ||
else | ||
if e.node.present? and e.node.situational? | ||
# Forbidden | ||
end | ||
end | ||
end | ||
|
||
# Postal Code | ||
n4.element(3).tap do |e| | ||
if usa_canada and e.node =~ /^(\d{1,8}|\d{10,})$/ | ||
acc.warn(e, "must be 9-digits for usa") | ||
end | ||
end | ||
|
||
# Country Code | ||
n4.element(4).tap do |e| | ||
if usa_canada | ||
if e.node.present? and e.node.situational? | ||
# Forbidden | ||
end | ||
else | ||
# Country codes 2-digit from ISO 3166 | ||
end | ||
end | ||
|
||
# Country Subdivision Code | ||
# n4.element(7).tap do |e| | ||
# if usa_canada | ||
# if e.node.present? and e.node.situational? | ||
# # Forbidden | ||
# end | ||
# else | ||
# # Country subdivision codes from ISO 3166 | ||
# end | ||
# end | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters