Class: Zeiger::FileInfo
- Inherits:
-
Object
- Object
- Zeiger::FileInfo
- Defined in:
- lib/zeiger/file_info.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#ngrams ⇒ Object
Returns the value of attribute ngrams.
Instance Method Summary collapse
- #add_ngram(ngram) ⇒ Object
-
#initialize(dir, filename) ⇒ FileInfo
constructor
A new instance of FileInfo.
- #local_filename ⇒ Object
- #match(regex) ⇒ Object
Constructor Details
#initialize(dir, filename) ⇒ FileInfo
Returns a new instance of FileInfo.
7 8 9 |
# File 'lib/zeiger/file_info.rb', line 7 def initialize dir, filename @dir, @filename, @ngrams = dir, filename, Set.new end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
5 6 7 |
# File 'lib/zeiger/file_info.rb', line 5 def dir @dir end |
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/zeiger/file_info.rb', line 5 def filename @filename end |
#ngrams ⇒ Object
Returns the value of attribute ngrams.
5 6 7 |
# File 'lib/zeiger/file_info.rb', line 5 def ngrams @ngrams end |
Instance Method Details
#add_ngram(ngram) ⇒ Object
19 20 21 |
# File 'lib/zeiger/file_info.rb', line 19 def add_ngram ngram @ngrams << ngram end |
#local_filename ⇒ Object
11 12 13 |
# File 'lib/zeiger/file_info.rb', line 11 def local_filename @_local_filename ||= filename.gsub(/^#{Regexp.escape dir}\//, "") end |
#match(regex) ⇒ Object
15 16 17 |
# File 'lib/zeiger/file_info.rb', line 15 def match regex local_filename.match regex end |