asodhaosidisgdafiuusd 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/fizzbuzz_approach5.rb +35 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b5e8eaac3fc6a417a33d4aeac8ee18ae841604ac103803825898077fbecda0ad
4
+ data.tar.gz: 216dd7f1fc47eee4e3b006bf92a127741042420e59098181cee2ac4e9915d832
5
+ SHA512:
6
+ metadata.gz: e165d9e3b716880997f0cebf80d73c32d66fedfe9cdfd9db6b725805b102899ea642b936613571fcbcec6293c03f67fa971c9266940e8d4561b57a8691d6606e
7
+ data.tar.gz: 3bd52f15bffea38f5f935576ed984c7d5cb830a6cc610ff4365acd8ad4b421a5eddbe361a9f6adb15636f4e08d8b4638994d087a596e07c77766c3de32ccd04e
@@ -0,0 +1,35 @@
1
+ # approach 5
2
+ # ===================================================
3
+ # Functional requirement - Fizzbuzz traditional game
4
+ # Non-Functional requirement - Maintainability + Availability + Testability + Usability
5
+ # Trade-off => Time => O(mn)
6
+
7
+ class Fizzbuzz
8
+
9
+ # define default value
10
+ DEFAULT_START = 1
11
+ DEFAULT_FINISH = 100
12
+ DEFAULT_CON = {"Fizz" => 3, "Buzz" => 5}
13
+
14
+ # check whether denom is a multiple of num
15
+ # require 2 params
16
+ # @num = numerator
17
+ # @denom = denominator
18
+ # @return boolean
19
+ def self.multiple_of(num, denom)
20
+ num % denom == 0 ? true : false
21
+ end
22
+
23
+ # print Fizz when i is multiple of 3 and print Buzz when i is multiple of 5
24
+ # require 3 params
25
+ # @start = starting point
26
+ # @finish = finishing point
27
+ # @condition = game trigger
28
+ # @return array of result
29
+ def self.start(start=DEFAULT_START, finish=DEFAULT_FINISH, condition=DEFAULT_CON)
30
+ (start..finish).map do |i|
31
+ array = condition.select {|key, value| multiple_of(i, value)}
32
+ array.size > 0 ? array.map{|key| key.first}.join : i
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asodhaosidisgdafiuusd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Saruj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Fizzbuzz.start(start, finish, {'Fizz' => 3, 'Buzz' => 5})
14
+ email: Saruj.s@ku.th
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/fizzbuzz_approach5.rb
20
+ homepage: https://rubygems.org/gems/asodhaosidisgdafiuusd
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: []