Class: ADN::File
- Inherits:
-
Object
- Object
- ADN::File
- Defined in:
- lib/adn/file.rb
Instance Attribute Summary collapse
-
#complete ⇒ Object
Returns the value of attribute complete.
- #created_at ⇒ Object
-
#file_id ⇒ Object
Returns the value of attribute file_id.
-
#file_token ⇒ Object
Returns the value of attribute file_token.
-
#id ⇒ Object
Returns the value of attribute id.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
-
#name ⇒ Object
Returns the value of attribute name.
-
#public ⇒ Object
Returns the value of attribute public.
-
#sha1 ⇒ Object
Returns the value of attribute sha1.
-
#size ⇒ Object
Returns the value of attribute size.
-
#source ⇒ Object
Returns the value of attribute source.
-
#total_size ⇒ Object
Returns the value of attribute total_size.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_expires ⇒ Object
Returns the value of attribute url_expires.
- #user ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #details ⇒ Object
-
#initialize(raw_file) ⇒ File
constructor
A new instance of File.
- #set_values(values) ⇒ Object
Constructor Details
#initialize(raw_file) ⇒ File
Returns a new instance of File.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/adn/file.rb', line 21 def initialize(raw_file) if raw_file.respond_to?(:each_pair) set_values(raw_file) file_id = id else file_id = raw_file file_details = details if file_details.has_key? "data" set_values(file_details["data"]) end end end |
Instance Attribute Details
#complete ⇒ Object
Returns the value of attribute complete.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def complete @complete end |
#created_at ⇒ Object
45 46 47 |
# File 'lib/adn/file.rb', line 45 def created_at DateTime.parse(@created_at) end |
#file_id ⇒ Object
Returns the value of attribute file_id.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def file_id @file_id end |
#file_token ⇒ Object
Returns the value of attribute file_token.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def file_token @file_token end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def id @id end |
#kind ⇒ Object
Returns the value of attribute kind.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def kind @kind end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def mime_type @mime_type end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def name @name end |
#public ⇒ Object
Returns the value of attribute public.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def public @public end |
#sha1 ⇒ Object
Returns the value of attribute sha1.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def sha1 @sha1 end |
#size ⇒ Object
Returns the value of attribute size.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def size @size end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def source @source end |
#total_size ⇒ Object
Returns the value of attribute total_size.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def total_size @total_size end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def url @url end |
#url_expires ⇒ Object
Returns the value of attribute url_expires.
5 6 7 |
# File 'lib/adn/file.rb', line 5 def url_expires @url_expires end |
Class Method Details
Instance Method Details
#delete ⇒ Object
53 54 55 56 |
# File 'lib/adn/file.rb', line 53 def delete result = ADN::API::File.delete(id) ADN.create_instance(result["data"], File) end |
#details ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/adn/file.rb', line 34 def details if id value = self.instance_variables.map do |i| [i.to_s.slice(1..-1), self.instance_variable_get(i)] end Hash[value] else ADN::API::File.by_id(file_id) end end |
#set_values(values) ⇒ Object
58 59 60 |
# File 'lib/adn/file.rb', line 58 def set_values(values) values.each_pair { |k, v| send("#{k}=", v) if respond_to?("#{k}=") } end |