Module: Brief::Document::Attachments

Included in:
Brief::Document
Defined in:
lib/brief/document/attachments.rb

Instance Method Summary collapse

Instance Method Details

#attachment_pathsObject



12
13
14
15
16
17
18
19
# File 'lib/brief/document/attachments.rb', line 12

def attachment_paths
  attachments.reduce({}.to_mash) do |memo, name|
    if asset = briefcase.find_asset(name)
      memo[name] = asset.realpath.to_s
      memo
    end
  end
end

#attachmentsObject



8
9
10
# File 'lib/brief/document/attachments.rb', line 8

def attachments
  Array(data.attachments)
end

#has_attachments?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/brief/document/attachments.rb', line 4

def has_attachments?
  attachments.length > 0
end

#render_attachmentsObject



21
22
23
24
25
26
27
28
# File 'lib/brief/document/attachments.rb', line 21

def render_attachments
  attachments.reduce({}.to_mash) do |memo, name|
    if asset = briefcase.find_asset(name)
      memo[name] = IO.read(asset) if asset.to_s.match(/\.svg/i)
      memo
    end
  end
end