Class: PPZ::Folder::AbstractFileModel

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

Direct Known Subclasses

OtherFileModel, PPZFileModel

Instance Attribute Summary collapse

Attributes inherited from AbstractModel

#index

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractModel

#get_css_path

Constructor Details

#initialize(path, level) ⇒ AbstractFileModel

Returns a new instance of AbstractFileModel.



14
15
16
17
18
19
20
21
22
# File 'lib/parser/folder/model/file/abstract.rb', line 14

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

Returns the value of attribute file_ext.



12
13
14
# File 'lib/parser/folder/model/file/abstract.rb', line 12

def file_ext
  @file_ext
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/parser/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/parser/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