Class: String
Instance Method Summary collapse
Instance Method Details
#hexlify ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby-ext.rb', line 38 def hexlify l,n,ls,s=0,0,[''],self.dup while s.size>0 l = s.slice!(0,16) ls << format("0x%4.4x: %s", n, l.unpack("n#{l.size/2}").collect { |x| format("%4.4x",x) }.join(' ')) n+=1 end if l.size%2 >0 ns = l.size>1 ? 1 : 0 ls.last << format("%s%2.2x",' '*ns,l[-1].pack('C')[0]) end ls end |
#to_camel ⇒ Object
35 36 37 |
# File 'lib/ruby-ext.rb', line 35 def to_camel split('_').collect {|x| x.capitalize}.join end |
#to_underscore ⇒ Object
32 33 34 |
# File 'lib/ruby-ext.rb', line 32 def to_underscore gsub(/([A-Z]+|[A-Z][a-z])/) {|x| ' ' + x }.gsub(/[A-Z][a-z]+/) {|x| ' ' + x }.split.collect{|x| x.downcase}.join('_') end |