Class: String

Inherits:
Object
  • Object
show all
Defined in:
library/blur/logging.rb,
library/blur/enhancements.rb

Overview

Reopens the scope of the standard String-class to extend it with helpful methods.

Instance Method Summary collapse

Instance Method Details

#^(c) ⇒ Object



5
6
7
# File 'library/blur/logging.rb', line 5

def ^ c
  self
end

#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.

Yield Returns:

  • (Array)

    list of elements in each slice consecutively.

Returns:

  • (Enumerator)

    list of slices.



33
34
35
# File 'library/blur/enhancements.rb', line 33

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.

Returns:

  • (Boolean)

    true if it is a numeric value.



24
25
26
# File 'library/blur/enhancements.rb', line 24

def numeric?
  self =~ /^\d+$/
end