Module: WNS::FilePropertyFilters

Defined in:
lib/jekyll-wns/assets/file_property_filters.rb

Instance Method Summary collapse

Instance Method Details

#file_size(path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll-wns/assets/file_property_filters.rb', line 5

def file_size(path)
  source = Jekyll.configuration({})['source']
  
  unless source.empty?
    source += '/'
  else 
    source = ''
  end 
  full_path = source + path

  unless path.nil?
    File.size full_path
  else
    0
  end
end

#mp3_duration(path) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jekyll-wns/assets/file_property_filters.rb', line 22

def mp3_duration(path)
  source = Jekyll.configuration({})['source'] || ''
  
  unless source.empty?
    source += '/'
  else 
    source = ''
  end 
  full_path = source + path

  unless path.nil?
    Mp3Info.open(full_path).length.to_i
  else
    0
  end
end