Class: Zandelok::Functions

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

Class Method Summary collapse

Class Method Details

.generate_hashtag(input) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/zandelok/functions.rb', line 23

def self.generate_hashtag(input)
  case input
  when Array
    Helpers::HashtagHelper.make_hashtag(input)
  when String
    Helpers::HashtagHelper.make_hashtag(input.split)
  else
    raise Errors::TypeError, 'Method accept only array or string'
  end
end

.missing_numbers(numbers) ⇒ Object

Raises:



15
16
17
18
19
20
21
# File 'lib/zandelok/functions.rb', line 15

def self.missing_numbers(numbers)
  raise Errors::TypeError, 'Method accept only array' unless numbers.is_a?(Array)
  raise Errors::TypeError, 'Array should consist of integers only' unless numbers.all?(Integer)
  raise Errors::DataError, 'Array should consist of two or more variables' unless numbers.size >= 2

  [*numbers.min..numbers.max] - numbers
end

.multiply(*args) ⇒ Object

Raises:



8
9
10
11
12
13
# File 'lib/zandelok/functions.rb', line 8

def self.multiply(*args)
  raise Errors::TypeError, 'Method accept only integers' unless args.all?(Integer)
  raise Errors::DataError, 'Method should accept two or more values' unless args.size >= 2

  args.reduce(:*)
end