Module: Pageflow::FilesHelper

Defined in:
app/helpers/pageflow/files_helper.rb

Instance Method Summary collapse

Instance Method Details

#file_dimensions(file) ⇒ Object



7
8
9
10
11
12
13
# File 'app/helpers/pageflow/files_helper.rb', line 7

def file_dimensions(file)
  if file.width && file.height
    "#{file.width} x #{file.height}px"
  else
    "-"
  end
end

#file_duration(file) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/pageflow/files_helper.rb', line 15

def file_duration(file)
  if file.duration_in_ms
    total_seconds = file.duration_in_ms / 1000
    seconds = total_seconds % 60
    minutes = (total_seconds / 60) % 60
    hours = total_seconds / (60 * 60)

    format("%02d:%02d:%02d", hours, minutes, seconds)
  else
    "-"
  end
end

#file_format(file) ⇒ Object



3
4
5
# File 'app/helpers/pageflow/files_helper.rb', line 3

def file_format(file)
  file.format.presence || '-'
end