module WkhtmltopdfRunner::Utils
Constants
- BLANK_RE
Public Class Methods
blank?(obj)
click to toggle source
# File lib/wkhtmltopdf_runner/utils.rb, line 22 def self.blank?(obj) return !!BLANK_RE.match(obj) if obj.is_a?(String) obj.respond_to?(:empty?) ? !!obj.empty? : !obj end
dasherize(word)
click to toggle source
# File lib/wkhtmltopdf_runner/utils.rb, line 7 def self.dasherize(word) underscore(word).tr('_', '-') end
presence(obj)
click to toggle source
# File lib/wkhtmltopdf_runner/utils.rb, line 32 def self.presence(obj) obj if present?(obj) end
present?(obj)
click to toggle source
# File lib/wkhtmltopdf_runner/utils.rb, line 28 def self.present?(obj) !blank?(obj) end
underscore(camel_cased_word)
click to toggle source
# File lib/wkhtmltopdf_runner/utils.rb, line 11 def self.underscore(camel_cased_word) return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word) word = camel_cased_word.to_s.gsub('::', '/') word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr!('-', '_') word.downcase! word end