module Spyro::ActionViewExtension::CollectionForHelper::Output::Fields
Public Instance Methods
format_boolean(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 53 def format_boolean value, options value ? "Yes" : "No" end
format_classy_enum(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 33 def format_classy_enum value, options value.blank? ? "" : value.text end
format_cw_file(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 45 def format_cw_file value, options link_to value.file.filename, value.url unless value.file.nil? end
format_cw_image(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 41 def format_cw_image value, options cw_image_tag value, options[:version] end
format_datetime(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 37 def format_datetime value, options l(value, :format => options[:format] || :datetime) end
format_default(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 29 def format_default value, options value.to_s end
format_email(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 49 def format_email value, options mail_to value end
format_float(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 95 def format_float value, options value ? ("%.2f" % value) : "N/A" end
format_html(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 103 def format_html value, options "<span class='has-popover' data-html='true' data-content='#{@h.send(:h, value.to_s)}'>#{@h.truncate(@h.strip_tags(HTMLEntities.new.decode(value.to_s)), :length => 40, :separator => ' ')}</span>".html_safe end
format_period(values, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 57 def format_period values, options begin_at, end_at, current = *values current ||= Time.zone.now total, actual = (end_at.to_i - begin_at.to_i), (current.to_i - begin_at.to_i) current_percentage = [0, 100, (actual * 100) / total].sort.second <<EOP <div class="col-md-12"> <span class="date-before col-md-6 pull-left">#{l(begin_at, :format => options[:format] || :datetime)}</span> <span class="date-after col-md-6 pull-right">#{l(end_at, :format => options[:format] || :datetime)}</span> <div class="col-md-10 col-md-offset-1"> #{progress current_percentage} </div> </div> EOP end
format_prct(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 91 def format_prct value, options value ? ("%.2f%%" % value) : "N/A" end
format_progress(values, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 75 def format_progress values, options actual, total = *values current_percentage = [0, 100, (actual * 100) / total].sort.second rescue 0 <<EOP <div class="col-md-12"> <div class="col-md-12 percentage-label"> #{actual} / #{total} </div> <div class="col-md-10 col-md-offset-1"> #{progress current_percentage} </div> </div> EOP end
format_string(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 111 def format_string value, options value.to_s end
format_text(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 107 def format_text value, options "<span class='has-popover' data-content='#{@h.send(:h, value.to_s)}'>#{@h.truncate(value.to_s, :length => 40, :separator => ' ')}</span>".html_safe end
format_url(value, options)
click to toggle source
# File lib/spyro/collections/outputs/fields.rb, line 99 def format_url value, options link_to value, (value.start_with?('http') ? value : ('http://' + value)) end