Class: Lhj::Command::OSS::Del
- Inherits:
-
Lhj::Command::OSS
- Object
- CLAide::Command
- Lhj::Command
- Lhj::Command::OSS
- Lhj::Command::OSS::Del
- Defined in:
- lib/lhj/command/oss/del.rb
Class Method Summary collapse
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(argv) ⇒ Del
constructor
A new instance of Del.
- #validate! ⇒ Object
Methods inherited from Lhj::Command
Constructor Details
#initialize(argv) ⇒ Del
Returns a new instance of Del.
22 23 24 25 26 |
# File 'lib/lhj/command/oss/del.rb', line 22 def initialize(argv) @key = argv.option('key') @type = argv.option('type') super end |
Class Method Details
.options ⇒ Object
15 16 17 18 19 20 |
# File 'lib/lhj/command/oss/del.rb', line 15 def self. [ %w[--key OSS对应的key], %w[--type OSS对应的类型] ] end |
Instance Method Details
#handle ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lhj/command/oss/del.rb', line 33 def handle if @type objects = Lhj::OSS::Helper.instance.list objects.each do |o| if /#{@type}/ =~ o.key puts "成功删除#{o.key}" Lhj::OSS::Helper.instance.delete(o.key) end end else Lhj::OSS::Helper.instance.delete(@key) end end |
#validate! ⇒ Object
28 29 30 31 |
# File 'lib/lhj/command/oss/del.rb', line 28 def validate! help! '请输入key或者类型' unless @key || @type super end |