class Miam::Utils
Public Class Methods
bytesize(str)
click to toggle source
# File lib/miam/utils.rb, line 11 def bytesize(str) if str.respond_to?(:bytesize) str.bytesize else str.length end end
camelize(str)
click to toggle source
# File lib/miam/utils.rb, line 7 def camelize(str) str.slice(0, 1).upcase + str.slice(1..-1).downcase end
diff(obj1, obj2, options = {})
click to toggle source
# File lib/miam/utils.rb, line 19 def diff(obj1, obj2, options = {}) diffy = Diffy::Diff.new( obj1.pretty_inspect, obj2.pretty_inspect, :diff => '-u' ) out = diffy.to_s(options[:color] ? :color : :text).gsub(/\s+\z/m, '') out.gsub!(/^/, options[:indent]) if options[:indent] out end
unbrace(str)
click to toggle source
# File lib/miam/utils.rb, line 3 def unbrace(str) str.sub(/\A\s*\{/, '').sub(/\}\s*\z/, '') end