Method: Uttk::Logger::Path#rpath

Defined in:
lib/uttk/logger/path.rb

#rpath(re, &block) ⇒ Object

Raises:

  • (NotImplementedError)


108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/uttk/logger/path.rb', line 108

def rpath ( re, &block )
  # We work with uncaptured path here

  args = []

  raise NotImplementedError unless re.root? or re.final?

  re_segs = re.segments
  segs = to_a

  if re.final?
    re_segs = re_segs.reverse
    segs = segs.reverse
  end

  re_segs.zip(segs).each do |re_seg, seg|
    if re.negative?
      break if seg.nil? or re_seg !~ seg.to_s
      return
    else
      return if seg.nil?
      if match_data = re_seg =~ seg.to_s
        args << match_data.to_a[1..-1]
      else
        return
      end
    end
  end

  args.reverse! if re.final?

  block[self, *args.flatten]
  nil
end