Class: FilenameParser
- Inherits:
-
Object
- Object
- FilenameParser
- Defined in:
- lib/trex.rb
Overview
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #filestate=(state) ⇒ Object
- #handle(string, index, lines) ⇒ Object
-
#initialize ⇒ FilenameParser
constructor
A new instance of FilenameParser.
- #parse(string) ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize ⇒ FilenameParser
Returns a new instance of FilenameParser.
682 683 684 |
# File 'lib/trex.rb', line 682 def initialize @nesting = [] end |
Instance Method Details
#empty? ⇒ 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 |
#state ⇒ Object
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 |