Sha256: 6a929f74c023c6166932d93d6ffe2644b9391217e761dff115234671f27a8163
Contents?: true
Size: 832 Bytes
Versions: 8
Compression:
Stored size: 832 Bytes
Contents
String.class_eval do def dirname File.expand_path(File.dirname(self)) end def parent_dirname File.expand_path(File.dirname(self) + "/..") end def to_reader self.to_sym end def to_writer "#{self}=".to_sym end def to_iv "@#{self}" end def interpolate binding binding.must_be.a Binding return gsub(/\#\{.+?\}/) do |term| identifier = term.slice(2 .. term.size-2) binding.eval identifier end end def self.secure_token original = [Time.now, (1..10).map{ rand.to_s }] Digest::SHA1.hexdigest(original.flatten.join('--')) end def underscore word = self.dup word.gsub!(/::/, '/') word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') word.tr!("-", "_") word.downcase! word end end
Version data entries
8 entries across 8 versions & 2 rubygems