Module: AuxiliaryAddons::HtmlHelper
- Defined in:
- lib/auxiliary_addons/html_helper.rb
Instance Method Summary collapse
- #erase_spaces(str) ⇒ Object
- #hash_to_string(params = {}) ⇒ Object
- #last_id(key) ⇒ Object
- #newlines_to_htmlbrs(str) ⇒ Object
- #unique_id(key) ⇒ Object
Instance Method Details
#erase_spaces(str) ⇒ Object
29 30 31 32 |
# File 'lib/auxiliary_addons/html_helper.rb', line 29 def erase_spaces(str) return str if (str.nil? || str.blank?) str.gsub!(/\s/, '') end |
#hash_to_string(params = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/auxiliary_addons/html_helper.rb', line 10 def hash_to_string(params = {}) result = "" params.each do |key, value| blank = result.blank? result += (key.to_s + "=" + value.to_s) if blank result += ("&" + key.to_s + "=" + value.to_s) if !blank end # TODO: replace whitespaced and etc result end |
#last_id(key) ⇒ Object
43 44 45 |
# File 'lib/auxiliary_addons/html_helper.rb', line 43 def last_id(key) key + "." + @unique_ids[key].to_s end |
#newlines_to_htmlbrs(str) ⇒ Object
23 24 25 26 |
# File 'lib/auxiliary_addons/html_helper.rb', line 23 def newlines_to_htmlbrs(str) return str if (str.nil? || str.blank?) str.gsub!(/\n/, '</br>') end |
#unique_id(key) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/auxiliary_addons/html_helper.rb', line 35 def unique_id(key) @unique_ids = Hash.new() if @unique_ids.nil? @unique_ids[key] = 0 if @unique_ids[key].nil? @unique_ids[key] += 1 last_id(key) end |