From 1500b711db1c9a553f156626ad8e813affd4eaf9 Mon Sep 17 00:00:00 2001 From: taiki Date: Tue, 2 Aug 2022 15:11:41 +0900 Subject: [PATCH 1/4] Add output GitHub --- lib/fizzbuzz.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index 4746a88..dc149cc 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -6,6 +6,8 @@ def calculate number 'fizz' elsif number % 5 == 0 'buzz' + elsif number.to_s.include? '7' + 'GitHub' else number end From 0061d5c0e34b2863c8449789e32bc28b4927f15b Mon Sep 17 00:00:00 2001 From: taiki Date: Tue, 2 Aug 2022 15:19:02 +0900 Subject: [PATCH 2/4] Fix indent --- lib/fizzbuzz.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index dc149cc..f982fbb 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -6,7 +6,7 @@ def calculate number 'fizz' elsif number % 5 == 0 'buzz' - elsif number.to_s.include? '7' + elsif number.to_s.include? '7' 'GitHub' else number From c13720e9bce5dadcf24da1823fa4b88e3d499319 Mon Sep 17 00:00:00 2001 From: taiki Date: Tue, 2 Aug 2022 15:28:13 +0900 Subject: [PATCH 3/4] Add testcode_{17,27,75,77} --- spec/fizzbuzz_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/fizzbuzz_spec.rb b/spec/fizzbuzz_spec.rb index 93a63e6..16a057b 100644 --- a/spec/fizzbuzz_spec.rb +++ b/spec/fizzbuzz_spec.rb @@ -20,4 +20,10 @@ it { subject.calculate(15).should eq 'fizzbuzz' } it { subject.calculate(30).should eq 'fizzbuzz' } end + context 'GitHub number' do + it { subject.calculate{17}.should eq 'GitHub' } + it { subject.calculate{27}.should eq 'GitHub' } + it { subject.calculate{75}.should eq 'GitHub' } + it { subject.calculate{77}.should eq 'GitHub' } + end end From 400c58449be9f8798a8a5e0e2ffbb4e9fef1b999 Mon Sep 17 00:00:00 2001 From: taiki Date: Tue, 2 Aug 2022 15:32:44 +0900 Subject: [PATCH 4/4] Fix 7-case-output_{27,75} --- lib/fizzbuzz.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fizzbuzz.rb b/lib/fizzbuzz.rb index f982fbb..f9a304d 100644 --- a/lib/fizzbuzz.rb +++ b/lib/fizzbuzz.rb @@ -1,13 +1,13 @@ class Fizzbuzz def calculate number - if number % 3 == 0 && number % 5 == 0 + if number.to_s.include? '7' + 'GitHub' + elsif number % 3 == 0 && number % 5 == 0 'fizzbuzz' elsif number % 3 == 0 'fizz' elsif number % 5 == 0 'buzz' - elsif number.to_s.include? '7' - 'GitHub' else number end