Class: BinderCore::FileRef
- Inherits:
-
Object
- Object
- BinderCore::FileRef
- Defined in:
- lib/binder_core/file_ref.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #dir? ⇒ Boolean
- #ext ⇒ Object
- #files ⇒ Object
- #full_name ⇒ Object
-
#initialize(path = nil) ⇒ FileRef
constructor
A new instance of FileRef.
- #name ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ FileRef
Returns a new instance of FileRef.
5 6 7 |
# File 'lib/binder_core/file_ref.rb', line 5 def initialize path = nil @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/binder_core/file_ref.rb', line 4 def path @path end |
Instance Method Details
#dir? ⇒ Boolean
21 22 23 |
# File 'lib/binder_core/file_ref.rb', line 21 def dir? File.directory?(@path) end |
#ext ⇒ Object
17 18 19 |
# File 'lib/binder_core/file_ref.rb', line 17 def ext File.extname(@path) end |
#files ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/binder_core/file_ref.rb', line 25 def files # return an array of File objects for each file in this directory # if it is not at Directory return an empty array fls = [] if self.dir? Dir.foreach(@path) do |fname| next if fname == '.' or fname == '..' fls << fname end end fls end |
#full_name ⇒ Object
13 14 15 |
# File 'lib/binder_core/file_ref.rb', line 13 def full_name File.basename( @path ) end |
#name ⇒ Object
9 10 11 |
# File 'lib/binder_core/file_ref.rb', line 9 def name File.basename( @path, File.extname(@path) ) end |