Class: PPZ::Folder::AbstractFileModel
- Inherits:
-
AbstractModel
- Object
- AbstractModel
- PPZ::Folder::AbstractFileModel
- Defined in:
- lib/folder/model/file/abstract.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file_ext ⇒ Object
readonly
Returns the value of attribute file_ext.
Attributes inherited from AbstractModel
#father_model, #index, #level, #name, #next_model, #prev_model
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, level) ⇒ AbstractFileModel
constructor
A new instance of AbstractFileModel.
Methods inherited from AbstractModel
Constructor Details
#initialize(path, level) ⇒ AbstractFileModel
Returns a new instance of AbstractFileModel.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/folder/model/file/abstract.rb', line 12 def initialize path, level super temp_bn = @basename if /^(\d+)_/.match temp_bn @index = $1.to_i temp_bn = temp_bn[($1.size + 1)..-1] else @index = Float::INFINITY end /(.*)(\.[^\.]+)$/.match temp_bn @name = $1 || temp_bn @file_ext = $2 || '' end |
Instance Attribute Details
#file_ext ⇒ Object (readonly)
Returns the value of attribute file_ext.
11 12 13 |
# File 'lib/folder/model/file/abstract.rb', line 11 def file_ext @file_ext end |
Class Method Details
.from_path(path, level) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/folder/model/file/abstract.rb', line 3 def self.from_path path, level if (File.extname path) == '.ppz' PPZFileModel.new path, level else OtherFileModel.new path, level end end |