Class: Based::File

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

Overview

An object representing a file within the base directory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent) ⇒ File

initialise from name and containing directory



165
166
167
168
169
170
171
172
173
# File 'lib/based.rb', line 165

def initialize(name, parent)
  super()
  @name = name
  @parent = parent
  @base = @parent.base
  @relativePath = @parent.relativePath + @name
  @pathElements = @parent.pathElements + [name]
  @fullPath = @parent.fullPath + @name
end

Instance Attribute Details

#baseObject (readonly)

the base directory



153
154
155
# File 'lib/based.rb', line 153

def base
  @base
end

#fullPathObject (readonly)

full absolute path name of file



162
163
164
# File 'lib/based.rb', line 162

def fullPath
  @fullPath
end

#nameObject (readonly)

immediate name of file



147
148
149
# File 'lib/based.rb', line 147

def name
  @name
end

#parentObject (readonly)

parent, i.e. containing directory



150
151
152
# File 'lib/based.rb', line 150

def parent
  @parent
end

#pathElementsObject (readonly)

elements of file path (including the name) as an array



159
160
161
# File 'lib/based.rb', line 159

def pathElements
  @pathElements
end

#relativePathObject (readonly)

path of this file relative to base directory



156
157
158
# File 'lib/based.rb', line 156

def relativePath
  @relativePath
end