Class: Based::File
- Inherits:
-
Object
- Object
- Based::File
- Defined in:
- lib/based.rb
Overview
An object representing a file within the base directory
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
the base directory.
-
#fullPath ⇒ Object
readonly
full absolute path name of file.
-
#name ⇒ Object
readonly
immediate name of file.
-
#parent ⇒ Object
readonly
parent, i.e.
-
#pathElements ⇒ Object
readonly
elements of file path (including the name) as an array.
-
#relativePath ⇒ Object
readonly
path of this file relative to base directory.
Instance Method Summary collapse
-
#initialize(name, parent) ⇒ File
constructor
initialise from name and containing directory.
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
#base ⇒ Object (readonly)
the base directory
153 154 155 |
# File 'lib/based.rb', line 153 def base @base end |
#fullPath ⇒ Object (readonly)
full absolute path name of file
162 163 164 |
# File 'lib/based.rb', line 162 def fullPath @fullPath end |
#name ⇒ Object (readonly)
immediate name of file
147 148 149 |
# File 'lib/based.rb', line 147 def name @name end |
#parent ⇒ Object (readonly)
parent, i.e. containing directory
150 151 152 |
# File 'lib/based.rb', line 150 def parent @parent end |
#pathElements ⇒ Object (readonly)
elements of file path (including the name) as an array
159 160 161 |
# File 'lib/based.rb', line 159 def pathElements @pathElements end |
#relativePath ⇒ Object (readonly)
path of this file relative to base directory
156 157 158 |
# File 'lib/based.rb', line 156 def relativePath @relativePath end |