Class: File::Visitor::Filter::Ext
- Inherits:
-
Object
- Object
- File::Visitor::Filter::Ext
- Defined in:
- lib/file/visitor/filter/ext.rb
Instance Method Summary collapse
-
#initialize(extstr) ⇒ Ext
constructor
A new instance of Ext.
- #match?(path) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(extstr) ⇒ Ext
Returns a new instance of Ext.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/file/visitor/filter/ext.rb', line 6 def initialize(extstr) if extstr.nil? || !(extstr.is_a?(String) || extstr.is_a?(Symbol)) raise ArgumentError, "ext must be Sting/Symbol" end extstr = extstr.to_s unless extstr =~ /\A\./ extstr = ".#{extstr}" end @ext = extstr end |
Instance Method Details
#match?(path) ⇒ Boolean
17 18 19 20 |
# File 'lib/file/visitor/filter/ext.rb', line 17 def match?(path) ext = File.extname(path) ext == @ext end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/file/visitor/filter/ext.rb', line 22 def to_s "%s[%s]" % [self.class.name, @ext.to_s] end |