Module: DisplayHelper
- Defined in:
- lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb
Instance Method Summary collapse
- #display_time(disp_time, class_name = nil) ⇒ Object
- #scrap_word(text, char_count_limit, more_text = nil, more_link = nil, style = '') ⇒ Object
Instance Method Details
#display_time(disp_time, class_name = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb', line 30 def display_time(disp_time, class_name = nil) return distance_of_time_in_words_to_now(disp_time) + " ago" # return_str = "" # if ((Time.now - disp_time) < (6*24*60*60)) # return_str = distance_of_time_in_words_to_now(disp_time) + " ago" # else # return_str = "#{disp_time.strftime('%m/%d/%y')}" # end # # return content_tag("span", return_str, :class => (class_name.nil? ? "text-color-grey" : class_name)) end |
#scrap_word(text, char_count_limit, more_text = nil, more_link = nil, style = '') ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb', line 3 def scrap_word(text, char_count_limit, more_text = nil, more_link = nil,style='') # remove HTML tags text = text.to_s.gsub(/<\/?[^>]*>/, " ") # remove additional spaces text = text.to_s.gsub(/[ ]+/, " ") if text.length < char_count_limit return text end = "" words = text.split(/ /) words.each do |word| if word.length > 0 if ( + word).length > char_count_limit if more_text && more_link = + " " + link_to(more_text, more_link,:style=>style, :target=>"_blank") else = .strip + "..." end break; else = + word + " " end end end return end |