Class Uttk::Logger::Path
In: lib/uttk/logger/path.rb
Parent: Object

Methods

Public Class methods

[Source]

# File lib/uttk/logger/path.rb, line 37
      def initialize ( anArray=[] )
        @contents = []
        anArray.each { |x| self << x }
      end

Public Instance methods

[Source]

# 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

[Source]

# File lib/uttk/logger/path.rb, line 52
      def << ( seg )
        @contents <<
          case seg
            when Segment then seg
            else Segment.new seg
          end
      end

[Source]

# File lib/uttk/logger/path.rb, line 176
      def == ( rhs )
        rhs.is_a?(self.class) && @contents == rhs.instance_variable_get(:@contents)
      end

[Source]

# File lib/uttk/logger/path.rb, line 42
      def initialize_copy ( rhs )
        @contents = rhs.instance_variable_get(:@contents).map { |x| x.dup }
      end

[Source]

# 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

[Source]

# 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

[Source]

# 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

[Source]

# 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

[Source]

# File lib/uttk/logger/path.rb, line 61
      def to_a
        map { |x| x.segment }
      end

[Source]

# File lib/uttk/logger/path.rb, line 172
      def to_logger_path
        self
      end

[Source]

# File lib/uttk/logger/path.rb, line 103
      def to_regex_path
        RegexPath.new(to_regex_path_string)
      end

[Source]

# File lib/uttk/logger/path.rb, line 98
      def to_regex_path_string
        '/' + map { |x| x.regexp_quoted_segment }.join('/')
      end

[Source]

# File lib/uttk/logger/path.rb, line 76
      def to_s
        '/' + map { |x| x.quoted_segment }.join('/')
      end

[Validate]