Class: JScrambler::Project::File
- Inherits:
-
Object
- Object
- JScrambler::Project::File
- Defined in:
- lib/jscrambler/project/file.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(options = {}, client) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(options = {}, client) ⇒ File
Returns a new instance of File.
6 7 8 9 10 11 12 13 14 |
# File 'lib/jscrambler/project/file.rb', line 6 def initialize(={}, client) raise ArgumentError, 'Cannot create file without ID' unless ['id'] @id = ['id'] @project_id = ['project_id'] @client = client @extension = ['extension'] @filename = ['filename'] @size = ['size'] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/jscrambler/project/file.rb', line 4 def client @client end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
4 5 6 |
# File 'lib/jscrambler/project/file.rb', line 4 def extension @extension end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/jscrambler/project/file.rb', line 4 def filename @filename end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/jscrambler/project/file.rb', line 4 def id @id end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
4 5 6 |
# File 'lib/jscrambler/project/file.rb', line 4 def project_id @project_id end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/jscrambler/project/file.rb', line 4 def size @size end |
Instance Method Details
#download ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jscrambler/project/file.rb', line 16 def download client.handle_response(client.api.get("code/#{project_id}/#{id}.#{extension}")) do |response| to_file_path = File.join(client.config['filesDest'], "#{filename}") File.delete(to_file_path) if File.exist?(to_file_path) file_handler = File.open(to_file_path, 'w') file_handler.write(response) file_handler.close end true end |