Class: QcloudCos::FolderObject

Inherits:
Object
  • Object
show all
Includes:
Objectable
Defined in:
lib/qcloud_cos/model/folder_object.rb

Constant Summary collapse

MAXLENGTH =
20
RETAINED_SYMBOLS =
%w(/ ? * : | \ < > ")
RETAINED_FIELDS =
%w(con aux nul prn com0 com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt0 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9)

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Objectable

#initialize

Instance Attribute Details

#biz_attrObject

Returns the value of attribute biz_attr.



11
12
13
# File 'lib/qcloud_cos/model/folder_object.rb', line 11

def biz_attr
  @biz_attr
end

#ctimeObject

Returns the value of attribute ctime.



12
13
14
# File 'lib/qcloud_cos/model/folder_object.rb', line 12

def ctime
  @ctime
end

#mtimeObject

Returns the value of attribute mtime.



13
14
15
# File 'lib/qcloud_cos/model/folder_object.rb', line 13

def mtime
  @mtime
end

#nameObject

Returns the value of attribute name.



14
15
16
# File 'lib/qcloud_cos/model/folder_object.rb', line 14

def name
  @name
end

Class Method Details

.validate(path) ⇒ Object

校验文件夹路径

Parameters:

  • path (String)

    文件夹路径

Raises:

  • InvalidFolderPathError 如果文件夹路径不合法



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/qcloud_cos/model/folder_object.rb', line 21

def self.validate(path)
  if !path.end_with?('/')
    fail InvalidFolderPathError, '文件夹路径必须以 / 结尾'
  elsif !(names = path.split('/')).empty?
    if names.detect { |name| RETAINED_FIELDS.include?(name.downcase) }
      fail InvalidFolderPathError, %(文件夹名字不能是保留字段: '#{RETAINED_FIELDS.join("', '")}')
    elsif names.detect { |name| name.match(/[\/?*:|\\<>"]/) }
      fail InvalidFolderPathError, %(文件夹名字不能包含保留字符: '#{RETAINED_SYMBOLS.join("', '")}')
    elsif names.detect { |name| name.length > MAXLENGTH }
      fail InvalidFolderPathError, %(文件夹名字不能超过#{MAXLENGTH}个字符)
    end
  end
end