Public Instance methods
is_segment()
Optimized version of +r.is String+ that yields the next segment only if it is the final segment.
[show source]
# File lib/roda/plugins/optimized_segment_matchers.rb 46 def is_segment 47 rp = @remaining_path 48 if rp.getbyte(0) == 47 && !rp.index('/', 1) && (len = rp.length) > 1 49 always do 50 @remaining_path = "" 51 yield rp[1, len] 52 end 53 end 54 end
on_segment()
Optimized version of +r.on String+ that yields the next segment if there is a segment.
[show source]
# File lib/roda/plugins/optimized_segment_matchers.rb 26 def on_segment 27 rp = @remaining_path 28 if rp.getbyte(0) == 47 29 if last = rp.index('/', 1) 30 return false if last == 1 31 always do 32 @remaining_path = rp[last, rp.length] 33 yield rp[1, last-1] 34 end 35 elsif (len = rp.length) > 1 36 always do 37 @remaining_path = "" 38 yield rp[1, len] 39 end 40 end 41 end 42 end