Class: ErrorHandle

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

Overview

require ‘FizzBuzz’

Class Method Summary collapse

Class Method Details

.check_defined(*_args) ⇒ Object



29
30
31
32
33
34
# File 'lib/error_handle.rb', line 29

def check_defined(*_args)
  start = defined?(:args[0])
  stop = defined?(:args[1])
  puts raise 'Invalid Data' unless !start.nil? && !stop.nil?
  true
end

.check_int(num) ⇒ Object



36
37
38
# File 'lib/error_handle.rb', line 36

def check_int(num)
  num.is_a?(Integer)
end

.check_is_num(*args) ⇒ Object



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

def check_is_num(*args)
  unless check_int(args[0]) && check_int(args[1])
    raise 'Enter Number Values only'
  end

  true
end

.check_no_of_arg(*args) ⇒ Object



9
10
11
12
13
# File 'lib/error_handle.rb', line 9

def check_no_of_arg(*args)
  raise 'Invalid no of Arguments' unless args.length == 2

  true
end

.compare_num(*args) ⇒ Object



23
24
25
26
27
# File 'lib/error_handle.rb', line 23

def compare_num(*args)
  raise 'Enter a Valid Limit' unless args[0] < args[1]

  true
end

.error_check(*args) ⇒ Object



5
6
7
# File 'lib/error_handle.rb', line 5

def error_check(*args)
  check_no_of_arg(*args) && check_is_num(*args) && compare_num(*args) && check_defined(*args)
end