Skip to content
Browse files

Add String#substring_after

  • Loading branch information...
1 parent 1633262 commit 38a9a683a1be0a608a54760a2780b958d97176fb @aroben committed Apr 4, 2012
Showing with 8 additions and 1 deletion.
  1. +3 −1 lib/asciidag.rb
  2. +5 −0 lib/coreext/string.rb
View
4 lib/asciidag.rb
@@ -1,3 +1,5 @@
+require 'coreext/string'
+
module AsciiDag
def self.parse(text)
nodes = []
@@ -16,7 +18,7 @@ def self.parse(text)
while i < line.length
x = line.index NODE_REGEXP, i
break if x.nil?
- label = line[x, line.length - x][NODE_REGEXP]
+ label = line.substring_after(x)[NODE_REGEXP]
add_node.call Node.new(label, x, y)
i = x + label.length
end
View
5 lib/coreext/string.rb
@@ -0,0 +1,5 @@
+class String
+ def substring_after(index)
+ slice(index, length - index)
+ end
+end

0 comments on commit 38a9a68

Please sign in to comment.
Something went wrong with that request. Please try again.