aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-110/abigail/README.md1
-rw-r--r--challenge-110/abigail/ruby/ch-1.rb18
2 files changed, 19 insertions, 0 deletions
diff --git a/challenge-110/abigail/README.md b/challenge-110/abigail/README.md
index e1a9a3d534..93a73192a7 100644
--- a/challenge-110/abigail/README.md
+++ b/challenge-110/abigail/README.md
@@ -48,6 +48,7 @@ can completly ignore any white space in the input.
[Node.js](node/ch-1.js)
[Perl](perl/ch-1.pl)
[Python](python/ch-1.py)
+[Ruby](ruby/ch-1.rb)
### Blog
diff --git a/challenge-110/abigail/ruby/ch-1.rb b/challenge-110/abigail/ruby/ch-1.rb
new file mode 100644
index 0000000000..e0ea490dc7
--- /dev/null
+++ b/challenge-110/abigail/ruby/ch-1.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/ruby
+
+#
+# See ../README.md
+#
+
+#
+# Run as: ruby ch-1.rb < input-file
+#
+
+ARGF . each_line do |_|
+ if _ . gsub(/\s+/, "") # Remove white space
+ . sub(/^\+/, "00") # Replace leading + with 00
+ . sub(/^\([0-9]{2}\)/, "0000") # Replace leading (NN) with 0000
+ . match /^[0-9]{14}$/ # Exactly 14 digits should be left
+ then print (_)
+ end
+end