Module: PathMapper::BaseNode
Instance Attribute Summary collapse
-
#_name ⇒ Object
readonly
Returns the value of attribute _name.
-
#_path ⇒ Object
readonly
Returns the value of attribute _path.
Instance Method Summary collapse
- #_grep(reg, recursive = false) ⇒ Object
- #_grep_dirs(recursive = false) ⇒ Object
- #_grep_files(recursive = false) ⇒ Object
- #get_file_name(name) ⇒ Object
- #initialize(path) ⇒ Object
- #inspect ⇒ Object
- #to_s ⇒ Object (also: #to_str)
Instance Attribute Details
#_name ⇒ Object (readonly)
Returns the value of attribute _name.
17 18 19 |
# File 'lib/path_mapper.rb', line 17 def _name @_name end |
#_path ⇒ Object (readonly)
Returns the value of attribute _path.
16 17 18 |
# File 'lib/path_mapper.rb', line 16 def _path @_path end |
Instance Method Details
#_grep(reg, recursive = false) ⇒ Object
24 25 26 27 28 |
# File 'lib/path_mapper.rb', line 24 def _grep(reg, recursive=false) path = "#{@_path}#{'/**' if recursive}/*" files = Dir[path].select {|f| f =~ reg } FilesIterator.new(files) end |
#_grep_dirs(recursive = false) ⇒ Object
30 31 32 |
# File 'lib/path_mapper.rb', line 30 def _grep_dirs(recursive=false) self._grep(/.*/).select {|n| n.is_a? DirNode } end |
#_grep_files(recursive = false) ⇒ Object
34 35 36 |
# File 'lib/path_mapper.rb', line 34 def _grep_files(recursive=false) self._grep(/.*/).select {|n| n.is_a? FileNode } end |
#get_file_name(name) ⇒ Object
38 39 40 |
# File 'lib/path_mapper.rb', line 38 def get_file_name(name) name.scan(/[^\/]+/).last end |
#initialize(path) ⇒ Object
19 20 21 22 |
# File 'lib/path_mapper.rb', line 19 def initialize(path) @_path = path @_name = get_file_name(path) end |
#inspect ⇒ Object
46 47 48 |
# File 'lib/path_mapper.rb', line 46 def inspect self.to_s end |
#to_s ⇒ Object Also known as: to_str
42 43 44 |
# File 'lib/path_mapper.rb', line 42 def to_s @_path end |