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.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from AbstractModel
#father_model, #index, #level, #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.
13 14 15 16 17 18 19 20 21 |
# File 'lib/folder/model/file/abstract.rb', line 13 def initialize path, level super unless /^((\d+)_)?([^\.]+)(\.[^\.]+)?$/.match @basename throw '文件的命名方式不太理解哦:' + path end @index = $2?($2.to_i):(Float::INFINITY) @name = $3 @file_ext = $4 || '' end |
Instance Attribute Details
#file_ext ⇒ Object (readonly)
Returns the value of attribute file_ext.
12 13 14 |
# File 'lib/folder/model/file/abstract.rb', line 12 def file_ext @file_ext end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/folder/model/file/abstract.rb', line 3 def name @name end |
Class Method Details
.from_path(path, level) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/folder/model/file/abstract.rb', line 4 def self.from_path path, level if (File.extname path) == '.ppz' PPZFileModel.new path, level else OtherFileModel.new path, level end end |