Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- library/blur/enhancements.rb
Overview
Reopens the scope of the standard String-class to extend it with helpful methods.
Instance Method Summary collapse
-
#each_slice(size = 8) ⇒ Enumerator
(also: #each_block)
Split a string up in n chunks and then iterate through them, exactly like Enumerable#each_slice.
-
#numeric? ⇒ Boolean
Checks if the string contains nothing but a numeric value.
Instance Method Details
#each_slice(size = 8) ⇒ Enumerator Also known as: each_block
Split a string up in n chunks and then iterate through them, exactly like Enumerable#each_slice.
35 36 37 |
# File 'library/blur/enhancements.rb', line 35 def each_slice size = 8 self.chars.each_slice(size).each{|slice| yield slice.join } end |
#numeric? ⇒ Boolean
Checks if the string contains nothing but a numeric value.
26 27 28 |
# File 'library/blur/enhancements.rb', line 26 def numeric? self =~ /^\d+$/ end |