Class: BinderCore::FileRef

Inherits:
Object
  • Object
show all
Defined in:
lib/binder_core/file_ref.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/binder_core/file_ref.rb', line 21

def dir?
  File.directory?(@path)
end

#extObject



17
18
19
# File 'lib/binder_core/file_ref.rb', line 17

def ext
  File.extname(@path)
end

#filesObject



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_nameObject



13
14
15
# File 'lib/binder_core/file_ref.rb', line 13

def full_name
  File.basename( @path )
end

#nameObject



9
10
11
# File 'lib/binder_core/file_ref.rb', line 9

def name
  File.basename( @path, File.extname(@path) )
end