| Class | Uttk::Logger::Path |
| In: |
lib/uttk/logger/path.rb
|
| Parent: | Object |
# File lib/uttk/logger/path.rb, line 37 def initialize ( anArray=[] ) @contents = [] anArray.each { |x| self << x } end
# File lib/uttk/logger/path.rb, line 66 def + ( rhs ) if rhs.is_a? Path tab = rhs.instance_variable_get(:@contents) else tab = rhs.to_a end self.class.new(@contents + tab) end
# File lib/uttk/logger/path.rb, line 52 def << ( seg ) @contents << case seg when Segment then seg else Segment.new seg end end
# File lib/uttk/logger/path.rb, line 176 def == ( rhs ) rhs.is_a?(self.class) && @contents == rhs.instance_variable_get(:@contents) end
# File lib/uttk/logger/path.rb, line 42 def initialize_copy ( rhs ) @contents = rhs.instance_variable_get(:@contents).map { |x| x.dup } end
# File lib/uttk/logger/path.rb, line 81 def inspect return '/' if @contents.empty? result = '' each do |seg| result << '/' << seg.quoted_segment unless seg.options.empty? opts = [] opts << 'ordered' if seg.options[:ordered] if type = seg.options[:type] opts << "type: #{type}" end result << '[' << opts.join(', ') << ']' end end result end
# File lib/uttk/logger/path.rb, line 158 def lpath_prefix ( re ) re_segs = re.segments re_segs.zip(to_a).each_with_index do |args, i| re_seg, seg = args return true if seg.nil? return false unless re_seg =~ seg.to_s re_seg = re_segs[i+1] return true if re_seg and re_seg.captured? end raise ArgumentError, 'no capture' end
# 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
# File lib/uttk/logger/path.rb, line 144 def rpath_prefix ( re ) re_segs = re.segments re_segs.zip(to_a).each_with_index do |args, i| re_seg, seg = args return false if seg.nil? return false unless re_seg =~ seg.to_s re_seg = re_segs[i+1] return true if re_seg and re_seg.captured? end raise ArgumentError, 'no capture' end