Class: BigMachines::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/big_machines/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry) ⇒ Attachment



5
6
7
# File 'lib/big_machines/attachment.rb', line 5

def initialize(entry)
  @raw_attachment = entry
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



16
17
18
# File 'lib/big_machines/attachment.rb', line 16

def method_missing(method, *args)
  @raw_attachment[method.to_s]
end

Instance Attribute Details

#raw_attachmentObject (readonly)

Returns the value of attribute raw_attachment.



3
4
5
# File 'lib/big_machines/attachment.rb', line 3

def raw_attachment
  @raw_attachment
end

Instance Method Details

#write(file_path) ⇒ Object



9
10
11
12
13
14
# File 'lib/big_machines/attachment.rb', line 9

def write(file_path)
  data = Base64.strict_decode64(@raw_attachment["file_content"])
  File.open(file_path, 'wb') do |f|
    f.write(data)
  end
end