Class: NeocitiesRed::Services::File::Remover
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::File::Remover
- Defined in:
- lib/neocities_red/services/file/remover.rb
Overview
Deletes a single file from the remote Neocities site.
Displays progress and result feedback via CliDisplay.
Instance Attribute Summary collapse
-
#client ⇒ NeocitiesRed::Client
readonly
The authenticated API client.
-
#filepath ⇒ String
The remote file path to delete.
Instance Method Summary collapse
-
#initialize(client, filepath, display: NeocitiesRed::CliDisplay.new) ⇒ Remover
constructor
A new instance of Remover.
-
#remove ⇒ Hash
Deletes the file from the remote site.
Constructor Details
#initialize(client, filepath, display: NeocitiesRed::CliDisplay.new) ⇒ Remover
Returns a new instance of Remover.
25 26 27 28 29 |
# File 'lib/neocities_red/services/file/remover.rb', line 25 def initialize(client, filepath, display: NeocitiesRed::CliDisplay.new) @client = client @filepath = filepath @display = display end |
Instance Attribute Details
#client ⇒ NeocitiesRed::Client (readonly)
Returns the authenticated API client.
17 18 19 |
# File 'lib/neocities_red/services/file/remover.rb', line 17 def client @client end |
#filepath ⇒ String
Returns the remote file path to delete.
20 21 22 |
# File 'lib/neocities_red/services/file/remover.rb', line 20 def filepath @filepath end |
Instance Method Details
#remove ⇒ Hash
Deletes the file from the remote site.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/neocities_red/services/file/remover.rb', line 34 def remove @display.display_delete_progress(filepath) response = @client.delete(filepath) if response[:result] == "success" @display.display_delete_success else @display.display_delete_error(response) end response end |