Module: Card::Set::Type::File::Format

Extended by:
AbstractFormat
Included in:
Image::Format
Defined in:
card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb,
card/tmpsets/set/mod013-card-mod-carrierwave/type/file.rb

Instance Method Summary collapse

Instance Method Details

#handle_sourceObject



42
43
44
45
46
47
48
49
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 42

def handle_source
  source = _render_source
  return "" if source.blank?
  block_given? ? yield(source) : source
rescue => e
  Rails.logger.info "Error with file source: #{e.message}"
  tr :file_error
end

#selected_versionObject



51
52
53
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 51

def selected_version
  card.attachment
end

#short_contentObject



38
39
40
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 38

def short_content
  number_to_human_size card.attachment.size
end

#view: coreObject



32
33
34
35
36
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 32

view :core do
  handle_source do |source|
    card_url source
  end
end

#view: sourceObject



26
27
28
29
30
# File 'card/tmpsets/set/mod014-card-mod-carrierwave/type/file.rb', line 26

view :source do
  file = card.attachment
  return "" unless file.valid?
  contextualize_path file.url
end