Class: RailsAgents::GeneratedFile
- Inherits:
-
Data
- Object
- Data
- RailsAgents::GeneratedFile
- Defined in:
- lib/rails_agents/generated_file.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#file_id ⇒ Object
readonly
Returns the value of attribute file_id.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type
4 5 6 |
# File 'lib/rails_agents/generated_file.rb', line 4 def content_type @content_type end |
#data ⇒ Object (readonly)
Returns the value of attribute data
4 5 6 |
# File 'lib/rails_agents/generated_file.rb', line 4 def data @data end |
#file_id ⇒ Object (readonly)
Returns the value of attribute file_id
4 5 6 |
# File 'lib/rails_agents/generated_file.rb', line 4 def file_id @file_id end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename
4 5 6 |
# File 'lib/rails_agents/generated_file.rb', line 4 def filename @filename end |
#path ⇒ Object (readonly)
Returns the value of attribute path
4 5 6 |
# File 'lib/rails_agents/generated_file.rb', line 4 def path @path end |
Instance Method Details
#save(directory) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/rails_agents/generated_file.rb', line 5 def save(directory) dir = File.(directory) FileUtils.mkdir_p(dir) destination = File.join(dir, filename) File.binwrite(destination, data) self.class.new(file_id:, filename:, content_type:, data:, path: destination) end |
#size ⇒ Object
13 |
# File 'lib/rails_agents/generated_file.rb', line 13 def size = data.bytesize |