Class: Zensana::Asana::Attachment

Inherits:
Object
  • Object
show all
Includes:
Access
Defined in:
lib/zensana/models/asana/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Access

#asana_service

Constructor Details

#initialize(id) ⇒ Attachment

Returns a new instance of Attachment.



8
9
10
# File 'lib/zensana/models/asana/attachment.rb', line 8

def initialize(id)
  @attributes = fetch(id)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



29
30
31
# File 'lib/zensana/models/asana/attachment.rb', line 29

def method_missing(name, *args, &block)
  attributes[name.to_s] || super
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/zensana/models/asana/attachment.rb', line 6

def attributes
  @attributes
end

Instance Method Details

#downloadObject



12
13
14
# File 'lib/zensana/models/asana/attachment.rb', line 12

def download
  download_file unless downloaded?
end

#download!Object



16
17
18
19
# File 'lib/zensana/models/asana/attachment.rb', line 16

def download!
  File.delete full_path if downloaded?
  download_file
end

#downloaded?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/zensana/models/asana/attachment.rb', line 21

def downloaded?
  File.exist? full_path
end

#full_pathObject



25
26
27
# File 'lib/zensana/models/asana/attachment.rb', line 25

def full_path
  File.join(file_dir, attributes['name'])
end