Module: Flunkey::Helpers
- Defined in:
- lib/flunkey/helpers.rb
Constant Summary collapse
- DOWNLOAD_SPEEDS =
Byte per second
{ 'Modem'=>7000, 'EDGE'=>24500, 'DSL Light'=>96000, 'DSL 3000'=>375000, 'DSL 16000'=>2000000 }
Instance Method Summary collapse
- #breadcrumbs(root, path) ⇒ Object
- #config ⇒ Object
- #debug(obj) ⇒ Object
- #download_estimates(size) ⇒ Object
- #icon_for(path) ⇒ Object
- #localize(date) ⇒ Object (also: #l)
- #title ⇒ Object
- #to_url(root, path) ⇒ Object
Instance Method Details
#breadcrumbs(root, path) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/flunkey/helpers.rb', line 38 def (root, path) b = [root.dup] return b if root==path path.relative_path_from(root).descend{|p| b << root + p } b end |
#config ⇒ Object
13 14 15 |
# File 'lib/flunkey/helpers.rb', line 13 def config settings end |
#debug(obj) ⇒ Object
59 60 61 |
# File 'lib/flunkey/helpers.rb', line 59 def debug(obj) "<pre>#{Rack::Utils.escape_html obj.inspect}</pre>" end |
#download_estimates(size) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/flunkey/helpers.rb', line 45 def download_estimates(size) result = [] DOWNLOAD_SPEEDS.each do |name, speed| result << [name, (size/speed).round(1)] end result.sort{|a,b| b[1]<=>a[1]} end |
#icon_for(path) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/flunkey/helpers.rb', line 25 def icon_for(path) icon = case when path.directory? then "fa-folder" when path.bundle? then "fa-file-o" else "fa-file-o" end "<i class='fa #{icon}'></i>" end |
#localize(date) ⇒ Object Also known as: l
53 54 55 |
# File 'lib/flunkey/helpers.rb', line 53 def localize(date) date.strftime('%d.%m.%Y %H:%M') end |