lib/citrus.rb in citrus-3.0.1 vs lib/citrus.rb in citrus-3.0.2
- old
+ new
@@ -6,11 +6,11 @@
# Citrus is a compact and powerful parsing library for Ruby that combines the
# elegance and expressiveness of the language with the simplicity and power of
# parsing expressions.
#
-# http://mjijackson.com/citrus
+# http://mjackson.github.io/citrus
module Citrus
autoload :File, 'citrus/file'
# A pattern to match any character, including newline.
DOT = /./mu
@@ -197,11 +197,11 @@
end
end
# Returns the 0-based offset of the given +pos+ in the input on the line
# on which it is found. +pos+ defaults to the current pointer position.
- def line_offset(pos=pos)
+ def line_offset(pos=pos())
p = 0
string.each_line do |line|
len = line.length
return (pos - p) if p + len >= pos
p += len
@@ -209,11 +209,11 @@
0
end
# Returns the 0-based number of the line that contains the character at the
# given +pos+. +pos+ defaults to the current pointer position.
- def line_index(pos=pos)
+ def line_index(pos=pos())
p = n = 0
string.each_line do |line|
p += line.length
return n if p >= pos
n += 1
@@ -221,18 +221,18 @@
0
end
# Returns the 1-based number of the line that contains the character at the
# given +pos+. +pos+ defaults to the current pointer position.
- def line_number(pos=pos)
+ def line_number(pos=pos())
line_index(pos) + 1
end
alias_method :lineno, :line_number
# Returns the text of the line that contains the character at the given
# +pos+. +pos+ defaults to the current pointer position.
- def line(pos=pos)
+ def line(pos=pos())
lines[line_index(pos)]
end
# Returns +true+ when using memoization to cache match results.
def memoized?