Class: CounterUtils::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/counter_utils.rb

Class Method Summary collapse

Class Method Details

.count_numbers(input) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/counter_utils.rb', line 8

def self.count_numbers(input)
  if input.is_a?(String)
    input.scan(/\d+/).size
  elsif input.is_a?(Array)
    input.count { |element| element.is_a?(Numeric) }
  else
    0
  end
end