Class: String
Overview
:nodoc:
Instance Method Summary collapse
-
#ngrams(len = 1) ⇒ Object
Thanks to David Alan Black for this method, from ruby-talk post #11792.
- #to_underscore_sym ⇒ Object
Instance Method Details
#ngrams(len = 1) ⇒ Object
Thanks to David Alan Black for this method, from ruby-talk post #11792
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sbn/helpers.rb', line 48 def ngrams(len = 1) ngrams = [] len = size if len > size (0..size - len).each do |n| ng = self[n...(n + len)] ngrams.push(ng) yield ng if block_given? end ngrams end |
#to_underscore_sym ⇒ Object
42 43 44 |
# File 'lib/sbn/helpers.rb', line 42 def to_underscore_sym self.titleize.gsub(/\s+/, '').underscore.to_sym end |