hokkaido_dialect 0.2.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/README.md +15 -4
- data/lib/hokkaido_dialect/hokkaido_dialect.rb +34 -14
- data/lib/hokkaido_dialect/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f1eaaaa56aef31cdd2e3053f95400edfa7ce9c6df33c6b371ceb98fced9c42
|
4
|
+
data.tar.gz: ebbd87b4939f55b63ee3ad0f2aeae095e8907657762b7c8219ed70cc8557186e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e6f547d16d0283e15d78174a63b7c89bb60b2208dc309efcfda45fd367d394b5911e47b393b98014147acfc6dbff89862bc1e6e4a38d6a16ca8f26095464db
|
7
|
+
data.tar.gz: 743a25f646bdb1a0fb66ea9cc892b6b7e4eb6fab787e087ee3f1e53da1a210cf66a6536704d894d1e45898c394062c7d948bf53773ddfa58350efce2f26cb50d
|
data/README.md
CHANGED
@@ -24,13 +24,24 @@ Start an interactive quiz in IRB:
|
|
24
24
|
% irb
|
25
25
|
irb(main):001> require 'hokkaido_dialect'
|
26
26
|
=> true
|
27
|
-
irb(main):002> HokkaidoDialect::QuizGame.
|
28
|
-
=> 🦀🐻🐄💫✨
|
27
|
+
irb(main):002> HokkaidoDialect::QuizGame.play
|
29
28
|
```
|
30
29
|
|
31
|
-
|
30
|
+
### Play a quiz
|
32
31
|
|
33
|
-
|
32
|
+
```ruby
|
33
|
+
# 3 random questions (default)
|
34
|
+
HokkaidoDialect::QuizGame.play
|
35
|
+
|
36
|
+
# Specify the number of questions
|
37
|
+
HokkaidoDialect::QuizGame.play(5)
|
38
|
+
|
39
|
+
# Play with all questions
|
40
|
+
HokkaidoDialect::QuizGame.all
|
41
|
+
```
|
42
|
+
|
43
|
+
You will be asked multiple-choice questions on the correct usage of the Hokkaido dialect.
|
44
|
+
Enjoy the quiz and become familiar with the Hokkaido dialect! 🦀🐻🐄✨
|
34
45
|
|
35
46
|
## Development
|
36
47
|
|
@@ -27,8 +27,22 @@ module HokkaidoDialect
|
|
27
27
|
]
|
28
28
|
|
29
29
|
class QuizGame
|
30
|
-
def
|
31
|
-
|
30
|
+
def self.play(number_of_questions = 3)
|
31
|
+
play_questions(QUESTIONS.sample(number_of_questions))
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.all
|
35
|
+
play_questions(QUESTIONS.shuffle)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.play_questions(questions)
|
39
|
+
results = questions.map do |question|
|
40
|
+
new(question).ask_and_check
|
41
|
+
end
|
42
|
+
puts "#{questions.size}問中#{results.count(true)}問正解!"
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize(question = QUESTIONS.sample)
|
32
46
|
wrong_usage = question[:wrong_usage]
|
33
47
|
@dialect = question[:dialect]
|
34
48
|
@correct_usage = question[:correct_usage]
|
@@ -36,26 +50,32 @@ module HokkaidoDialect
|
|
36
50
|
end
|
37
51
|
|
38
52
|
def ask_and_check
|
39
|
-
puts
|
40
|
-
print '番号を入力してください(1 or 2): '
|
41
|
-
input = $stdin.gets.to_i
|
53
|
+
puts question_body
|
42
54
|
|
43
|
-
|
44
|
-
puts '無効な入力です!1または2を入力してください🐻'
|
45
|
-
return
|
46
|
-
end
|
55
|
+
input = input_until_valid
|
47
56
|
|
48
|
-
|
49
|
-
puts '正解!🎉✨🦀'
|
50
|
-
else
|
51
|
-
puts '不正解…🐄'
|
57
|
+
correct_answer?(input).tap do |judgment|
|
58
|
+
puts judgment ? '正解!🎉✨🦀' : '不正解…🐄'
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
55
|
-
def
|
62
|
+
def question_body
|
56
63
|
"次の文章で正しい「#{@dialect}」の使い方はどっち?\n1. #{@choices[0]}\n2. #{@choices[1]}"
|
57
64
|
end
|
58
65
|
|
66
|
+
def input_until_valid
|
67
|
+
loop do
|
68
|
+
print '番号を入力してください(1 or 2): '
|
69
|
+
input = $stdin.gets.to_i
|
70
|
+
|
71
|
+
if [1, 2].include?(input)
|
72
|
+
return input
|
73
|
+
end
|
74
|
+
|
75
|
+
puts '無効な入力です!1または2を入力してください🐻'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
59
79
|
def correct_answer?(input)
|
60
80
|
index = input - 1
|
61
81
|
@choices[index] == @correct_usage
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hokkaido_dialect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lemonade_37
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: 本物の北海道弁とエセ北海道弁を見分けるクイズです。
|
13
13
|
executables: []
|
@@ -26,7 +26,11 @@ files:
|
|
26
26
|
homepage: https://github.com/lemonade-37/hokkaido_dialect
|
27
27
|
licenses:
|
28
28
|
- MIT
|
29
|
-
metadata:
|
29
|
+
metadata:
|
30
|
+
homepage_uri: https://github.com/lemonade-37/hokkaido_dialect
|
31
|
+
source_code_uri: https://github.com/lemonade-37/hokkaido_dialect
|
32
|
+
bug_tracker_uri: https://github.com/lemonade-37/hokkaido_dialect/issues
|
33
|
+
documentation_uri: https://rubydoc.info/gems/hokkaido_dialect
|
30
34
|
rdoc_options: []
|
31
35
|
require_paths:
|
32
36
|
- lib
|
@@ -41,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
45
|
- !ruby/object:Gem::Version
|
42
46
|
version: '0'
|
43
47
|
requirements: []
|
44
|
-
rubygems_version: 3.6.
|
48
|
+
rubygems_version: 3.6.9
|
45
49
|
specification_version: 4
|
46
50
|
summary: 本物の北海道弁とエセ北海道弁を見分けるクイズです。
|
47
51
|
test_files: []
|