Class: NeocitiesRed::Services::File::Remover
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::File::Remover
- Defined in:
- lib/neocities_red/services/file/remover.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#filepath ⇒ Object
Returns the value of attribute filepath.
Instance Method Summary collapse
-
#initialize(client, filepath) ⇒ Remover
constructor
A new instance of Remover.
- #remove ⇒ Object
Constructor Details
#initialize(client, filepath) ⇒ Remover
Returns a new instance of Remover.
11 12 13 14 15 |
# File 'lib/neocities_red/services/file/remover.rb', line 11 def initialize(client, filepath) @client = client @filepath = filepath @pastel = Pastel.new(eachline: "\n") end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/neocities_red/services/file/remover.rb', line 9 def client @client end |
#filepath ⇒ Object
Returns the value of attribute filepath.
9 10 11 |
# File 'lib/neocities_red/services/file/remover.rb', line 9 def filepath @filepath end |
Instance Method Details
#remove ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/neocities_red/services/file/remover.rb', line 17 def remove puts @pastel.bold("Deleting #{filepath} ...") response = @client.delete(filepath) puts @pastel.bold(response[:message]) if response[:result] == "error" if response[:result] == "error" && response[:error_type] == "file_exists" print @pastel.yellow.bold("EXISTS") elsif response[:result] == "success" print @pastel.green.bold("SUCCESS") end response end |