Class: QcloudCos::FolderObject
- Inherits:
-
Object
- Object
- QcloudCos::FolderObject
- 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
-
#biz_attr ⇒ Object
Returns the value of attribute biz_attr.
-
#ctime ⇒ Object
Returns the value of attribute ctime.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.validate(path) ⇒ Object
校验文件夹路径.
-
.validate_name(names) ⇒ Object
校验文件夹名字.
Methods included from Objectable
Instance Attribute Details
permalink #biz_attr ⇒ Object
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 |
permalink #ctime ⇒ Object
Returns the value of attribute ctime.
12 13 14 |
# File 'lib/qcloud_cos/model/folder_object.rb', line 12 def ctime @ctime end |
permalink #mtime ⇒ Object
Returns the value of attribute mtime.
13 14 15 |
# File 'lib/qcloud_cos/model/folder_object.rb', line 13 def mtime @mtime end |
permalink #name ⇒ Object
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
permalink .validate(path) ⇒ Object
校验文件夹路径
21 22 23 24 25 26 27 |
# 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? validate_name(names) end end |
permalink .validate_name(names) ⇒ Object
校验文件夹名字
30 31 32 33 34 35 36 37 38 |
# File 'lib/qcloud_cos/model/folder_object.rb', line 30 def self.validate_name(names) 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 |