Class: FilenameParser

Inherits:
Object
  • Object
show all
Defined in:
lib/trex.rb

Overview

Instance Method Summary collapse

Constructor Details

#initializeFilenameParser

Returns a new instance of FilenameParser.



682
683
684
# File 'lib/trex.rb', line 682

def initialize
    @nesting = []
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


728
729
730
# File 'lib/trex.rb', line 728

def empty?
    return true
end

#filestate=(state) ⇒ Object



686
687
# File 'lib/trex.rb', line 686

def filestate=(state)
end

#handle(string, index, lines) ⇒ Object



689
690
691
692
693
694
695
# File 'lib/trex.rb', line 689

def handle(string, index, lines)
    unless string =~ /^\([\.\/]/ || string =~ /^\[[^\]]/ || string =~ /^\)/
        return false
    end
    self.parse(string)
    return true
end

#parse(string) ⇒ Object



697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
# File 'lib/trex.rb', line 697

def parse(string)
    while string and string != ""

        if string =~ /^\s+(.*)/
            string = $1
        end

        break unless string

        if string =~ /^\[[^\]]+\](.*)/
            string = $1
            next
        end

        if string =~ /^(\)+)(.*)/
            $1.size.times { @nesting.pop }
            break unless $2
            string = $2[1,$2.size]
            next
        end

        if string =~ /^\(([^\(\)\[]+)(.*)/
            @nesting.push($1)
            string = $2
            next
        end

        break
    end
end

#stateObject



732
733
734
735
736
737
# File 'lib/trex.rb', line 732

def state
    if @nesting.size <= 1
        return ""
    end
    return @nesting[1,@nesting.size].join("|") + ": "
end