Class: PPZ::Folder::AbstractFileModel

Inherits:
AbstractModel show all
Defined in:
lib/folder/model/file/abstract.rb

Direct Known Subclasses

OtherFileModel, PPZFileModel

Instance Attribute Summary collapse

Attributes inherited from AbstractModel

#father_model, #index, #level, #name, #next_model, #prev_model

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractModel

#relative_link

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_extObject (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