module Showbuilder::Corekit
Public Instance Methods
call_object_methods(object, methods)
click to toggle source
# File lib/showbuilder/corekit.rb, line 4 def call_object_methods(object, methods) unless object return end methods = Array.wrap(methods) if methods.count == 0 return end first_method = methods.first unless first_method return end unless object.respond_to?(first_method) return end method_result = object.send(first_method) if methods.count <= 1 return method_result else remaining_methods = methods.clone remaining_methods.shift return call_object_methods(method_result, remaining_methods) end end
contents_tag(tag_name, options = {}, &block)
click to toggle source
# File lib/showbuilder/corekit.rb, line 50 def contents_tag(tag_name, options = {}, &block) self.content_tag tag_name, options do self.html_contents(&block) end end
currency_string(number)
click to toggle source
# File lib/showbuilder/corekit.rb, line 60 def currency_string(number) if number number_to_currency(number) else '' end end
date_string(date)
click to toggle source
# File lib/showbuilder/corekit.rb, line 68 def date_string(date) case date when Date I18n.l(date) when Time time = date date = time.to_date I18n.l(date) else date.to_s end end
divc(option_class, &block)
click to toggle source
# File lib/showbuilder/corekit.rb, line 56 def divc(option_class, &block) contents_tag :div, :class => option_class , &block end
html_contents() { |contents| ... }
click to toggle source
# File lib/showbuilder/corekit.rb, line 37 def html_contents contents = [] result = yield contents if contents.count > 0 return contents.join(' ').html_safe end if result.respond_to?(:html_safe) return result.html_safe end end
merge_class_option(original, another)
click to toggle source
# File lib/showbuilder/corekit.rb, line 33 def merge_class_option(original, another) "#{original} #{another}".strip end
percent_string(number)
click to toggle source
# File lib/showbuilder/corekit.rb, line 81 def percent_string(number) if number number_to_percentage(number, :precision => 2) else '' end end
safe_html_string(text)
click to toggle source
# File lib/showbuilder/corekit.rb, line 97 def safe_html_string(text) if text.is_a?(String) text.gsub(/\n/, "<br/>").html_safe else text.to_s end end
time_string(time)
click to toggle source
# File lib/showbuilder/corekit.rb, line 89 def time_string(time) if time I18n.l(time) else '' end end