shinycolors 0.1.0 → 0.2.0
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/lib/shinycolors/idol.rb +56 -0
- data/lib/shinycolors/unit.rb +34 -0
- data/lib/shinycolors/version.rb +1 -1
- data/lib/shinycolors.rb +14 -15
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad13ae04aecffbe52eb37d7eba831555923072c2e27214932e2892b7ae83e268
|
4
|
+
data.tar.gz: 4eac4a3c368d7926283286c30629c02c8737900f2f8e82795a69ba5e24cedd01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 821deb56372525324414d304b90caf26f747fdb4f7a01dde5b2f55d65aa456588f8faf62d30859c28a889c3a8c99687b82621d057dc13ebb37adeeb8e0b91c66
|
7
|
+
data.tar.gz: 3063a6d27c500fe3aa45fa4b425ab8223f28df1595f5d40f4c8c3dbbe725e163be0669f03ccc2ab932635b701800ffb48c4fe04e7728c080c5d736314fa63b13
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'active_support/core_ext/hash'
|
3
|
+
|
4
|
+
module ShinyColors
|
5
|
+
class Idol
|
6
|
+
class NotFoundError < StandardError; end
|
7
|
+
|
8
|
+
def initialize(name:, cv:, age:, birthplace:, birthday:, nickname:)
|
9
|
+
@name = name
|
10
|
+
@cv = cv
|
11
|
+
@age = age
|
12
|
+
@birthplace = birthplace
|
13
|
+
@birthday = birthday
|
14
|
+
@nickname = nickname
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :name, :cv, :age, :birthplace, :birthday, :nickname
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def all
|
21
|
+
return @all unless @all.nil?
|
22
|
+
|
23
|
+
@all = YAML.load_file('./data/idol.yml').each_with_object({}) do |(_, values), result|
|
24
|
+
result.merge!(values['idols'])
|
25
|
+
end.deep_symbolize_keys!
|
26
|
+
end
|
27
|
+
|
28
|
+
def names
|
29
|
+
all.keys
|
30
|
+
end
|
31
|
+
|
32
|
+
def nicknames
|
33
|
+
all.each_with_object({}) do |(fullname, values), result|
|
34
|
+
values[:nickname]&.each { |nickname| result.merge!({ nickname => fullname }) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def find(name)
|
39
|
+
h = all[name]
|
40
|
+
raise(NotFoundError) if h.nil?
|
41
|
+
new(**h)
|
42
|
+
end
|
43
|
+
|
44
|
+
def display(name)
|
45
|
+
idol = find(name)
|
46
|
+
puts <<~PRETTY
|
47
|
+
名前: #{idol.name}
|
48
|
+
cv: #{idol.cv}
|
49
|
+
年齢: #{idol.age}
|
50
|
+
出身地: #{idol.birthplace}
|
51
|
+
誕生日: #{idol.birthday}
|
52
|
+
PRETTY
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module ShinyColors
|
4
|
+
class Unit
|
5
|
+
class NotFoundError < StandardError; end
|
6
|
+
|
7
|
+
def initialize(name:, name_jp:, color:, idols:)
|
8
|
+
@name = name
|
9
|
+
@name_jp = name_jp
|
10
|
+
@color = color
|
11
|
+
@idols = idols
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :name, :name_jp, :color, :idols
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def all
|
18
|
+
return @all unless @all.nil?
|
19
|
+
|
20
|
+
@all = YAML.load_file('./data/idol.yml').deep_symbolize_keys!
|
21
|
+
end
|
22
|
+
|
23
|
+
def names
|
24
|
+
all.keys
|
25
|
+
end
|
26
|
+
|
27
|
+
def find(name)
|
28
|
+
h = all[name]
|
29
|
+
raise(IdolNotFoundError) if h.nil?
|
30
|
+
new(**h)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/shinycolors/version.rb
CHANGED
data/lib/shinycolors.rb
CHANGED
@@ -1,25 +1,24 @@
|
|
1
1
|
require 'shinycolors/version'
|
2
|
-
require '
|
2
|
+
require 'shinycolors/idol'
|
3
|
+
require 'shinycolors/unit'
|
3
4
|
|
4
5
|
module ShinyColors
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def names
|
12
|
-
all.keys
|
6
|
+
class << self
|
7
|
+
Idol.names.each do |name|
|
8
|
+
define_method(name) do
|
9
|
+
Idol.find(name)
|
13
10
|
end
|
11
|
+
end
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
Idol.nicknames.each do |nickname, fullname|
|
14
|
+
define_method(nickname) do
|
15
|
+
Idol.find(fullname)
|
17
16
|
end
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
19
|
+
Unit.names.each do |name|
|
20
|
+
define_method(name) do
|
21
|
+
Unit.find(name)
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shinycolors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iavivai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'shinycolorsは「アイドルマスター シャイニーカラーズ」の情報をRubyで扱えるようにするためのgemです。
|
14
14
|
|
@@ -20,6 +20,8 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- lib/shinycolors.rb
|
23
|
+
- lib/shinycolors/idol.rb
|
24
|
+
- lib/shinycolors/unit.rb
|
23
25
|
- lib/shinycolors/version.rb
|
24
26
|
homepage: https://github.com/iavivai/shinycolors
|
25
27
|
licenses:
|