fizzbuzz_pm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/fizzbuzz.rb +56 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0cafb2d5c141f909e1b76da0f0e342c27a6f36171adfb2fe5201187d4f00fe91
|
4
|
+
data.tar.gz: 2f240686bb8d018f4709cb2417b2cac14bc09dc34c9230cba24c65d41f429561
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8bc1dcf60a9b902ca8478c9cbf195fbe40887976af4e9432cef85439046e44972f37961289bec0180232cc4016c5d7a9e73d6fc7635684a0f92ecf3214c365c2
|
7
|
+
data.tar.gz: 10e7189e600b424a4d9602840de15a990dc36ed69dec372e5b15142faec60ef5b3628613aa598291a7cba721ddae69be7c37739c42300174406c9c6a24084ed2
|
data/lib/fizzbuzz.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Module for Error Handling
|
2
|
+
module ErrorHandling
|
3
|
+
# Method to check wheter input given by user is Integer or not if not than it raise error message.
|
4
|
+
def is_a_integer(initial_range, final_range)
|
5
|
+
if initial_range.is_a?(Integer) && final_range.is_a?(Integer)
|
6
|
+
return false
|
7
|
+
else
|
8
|
+
return 'pelase give Integer as a input'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
#
|
12
|
+
def first_input_always_samller(initial_range, final_range)
|
13
|
+
if initial_range > final_range
|
14
|
+
return "First input is always samller!!!!"
|
15
|
+
end
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
#Method for checking the number input given by user are must be two if not it raise the error massage
|
19
|
+
def check_number_of_inputs(*args)
|
20
|
+
if args.length != 2
|
21
|
+
return "Please enter only two numbers"
|
22
|
+
end
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Fizzbuzz
|
28
|
+
extend ErrorHandling
|
29
|
+
def self.fizzbuzz(*args)
|
30
|
+
initial_range = args[0]
|
31
|
+
final_range = args[1]
|
32
|
+
if message = is_a_integer(initial_range, final_range)
|
33
|
+
puts message
|
34
|
+
return
|
35
|
+
elsif message = first_input_always_samller(initial_range, final_range)
|
36
|
+
puts message
|
37
|
+
return
|
38
|
+
elsif message = check_number_of_inputs(*args)
|
39
|
+
puts message
|
40
|
+
return
|
41
|
+
else
|
42
|
+
(initial_range..final_range).each do |number|
|
43
|
+
if number % 3 == 0 && number % 5 == 0
|
44
|
+
puts 'Fizz-Buzz'
|
45
|
+
elsif number % 3 == 0
|
46
|
+
puts 'Fizz'
|
47
|
+
elsif number % 5 == 0
|
48
|
+
puts 'Buzz'
|
49
|
+
else
|
50
|
+
puts number
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fizzbuzz_pm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Prashu Modi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: FizzBuzz gem
|
14
|
+
email: prashumodi47@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/fizzbuzz.rb
|
20
|
+
homepage: https://github.com/prashu47/fizzbuzz-_gem
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: FizzBuzz!
|
43
|
+
test_files: []
|