Module: Rudash::Utils

Defined in:
lib/utils/index.rb

Class Method Summary collapse

Class Method Details

.force_reverse(collection) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/utils/index.rb', line 15

def self.force_reverse(collection)
  case collection
  when Array then collection.reverse
  when Hash then collection.reverse_each.to_h
  when String then collection.reverse
  else []
  end
end

.function?(func) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/utils/index.rb', line 11

def self.function?(func)
  func.is_a?(Proc) || func.is_a?(Method)
end

.match_number?(str) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
# File 'lib/utils/index.rb', line 5

def self.match_number?(str)
  return false unless str.is_a?(String)

  str.match(/^(\d)+$/)
end