Module: WarclightHelper
- Defined in:
- app/helpers/warclight_helper.rb
Overview
Generic Helpers used in Warclight
Instance Method Summary collapse
Instance Method Details
#return_five(options = {}) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/helpers/warclight_helper.rb', line 19 def return_five( = {}) if [:value].length > 5 [:value][0, 5].join('; ') + '...' else [:value].join('; ') end end |
#url_to_link(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/warclight_helper.rb', line 6 def url_to_link( = {}) safe_join([:value].map do |url| res = Net::HTTP.get_response(URI(url)) if res.code.start_with?('1', '2', '3') link_to(url, url, target: '_blank', rel: 'noopener') << ' 🔗' else url + ' (Not available)' end rescue url + ' (Not available)' end, '') end |