Class: NeocitiesRed::Services::FileRemover
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::FileRemover
- 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) ⇒ FileRemover
constructor
A new instance of FileRemover.
- #remove ⇒ Object
Constructor Details
#initialize(client, filepath) ⇒ FileRemover
Returns a new instance of FileRemover.
10 11 12 13 14 |
# File 'lib/neocities_red/services/file_remover.rb', line 10 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.
8 9 10 |
# File 'lib/neocities_red/services/file_remover.rb', line 8 def client @client end |
#filepath ⇒ Object
Returns the value of attribute filepath.
8 9 10 |
# File 'lib/neocities_red/services/file_remover.rb', line 8 def filepath @filepath end |
Instance Method Details
#remove ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/neocities_red/services/file_remover.rb', line 16 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 |