shinycolors 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 669a14d72460f7bedd0001277b1ee317270cc8669306ab9ef72f35d16a56c1b8
4
+ data.tar.gz: fa8f3260dfb7f69ef2fcd180f7e2e0b03e2b3bc8ca5a08063109eb449adaf6f0
5
+ SHA512:
6
+ metadata.gz: 4f76d235c36552fbbbf35e63c43f043d80f72fb384f1dfdf91647edece459ade88539be1716595dfb6e800b07c93c4f9928b026ea8e307743cdb259ade3a102f
7
+ data.tar.gz: fa0e8a7c2fbd0f9670f235662f28e9aec2d72760050ddfdf7dc07e73ba8ce1ecc6628a5c763cd5370c186a1a7ea85707f2caa4e958181799e12778da2a3c15f8
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'shinycolors/version'
4
+ require 'shinycolors/idol'
5
+ require 'shinycolors/unit'
6
+
7
+ module ShinyColors
8
+ class << self
9
+ Idol.names.each do |name|
10
+ define_method(name) do
11
+ Idol.find(name)
12
+ end
13
+ end
14
+
15
+ Idol.nicknames.each do |nickname, fullname|
16
+ define_method(nickname) do
17
+ Idol.find(fullname)
18
+ end
19
+ end
20
+
21
+ Unit.names.each do |name|
22
+ define_method(name) do
23
+ Unit.find(name)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'active_support/core_ext/hash'
5
+
6
+ module ShinyColors
7
+ class Idol
8
+ class NotFoundError < StandardError; end
9
+
10
+ def initialize(name:, cv:, age:, birthplace:, birthday:, nickname_key:, nickname_kana:)
11
+ @name = name
12
+ @cv = cv
13
+ @age = age
14
+ @birthplace = birthplace
15
+ @birthday = birthday
16
+ @nickname_key = nickname_key
17
+ @nickname_kana = nickname_kana
18
+ end
19
+
20
+ attr_reader :name, :cv, :age, :birthplace, :birthday, :nickname_key, :nickname_kana
21
+
22
+ class << self
23
+ def all
24
+ return @all unless @all.nil?
25
+
26
+ @all = YAML.load_file('./data/idol.yml').each_with_object({}) do |(_, values), result|
27
+ result.merge!(values['idols'])
28
+ end.deep_symbolize_keys!
29
+ end
30
+
31
+ def names
32
+ all.keys
33
+ end
34
+
35
+ def nicknames
36
+ all.each_with_object({}) do |(fullname, values), result|
37
+ values[:nickname_key]&.each { |nickname| result.merge!({ nickname => fullname }) }
38
+ end
39
+ end
40
+
41
+ def find(name)
42
+ h = all[name]
43
+ raise(NotFoundError) if h.nil?
44
+
45
+ new(**h)
46
+ end
47
+
48
+ def display(name)
49
+ idol = find(name)
50
+ puts <<~PRETTY
51
+ 名前: #{idol.name}
52
+ cv: #{idol.cv}
53
+ 年齢: #{idol.age}
54
+ 出身地: #{idol.birthplace}
55
+ 誕生日: #{idol.birthday}
56
+ PRETTY
57
+ end
58
+ end
59
+
60
+ def nickname
61
+ nickname_kana
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module ShinyColors
6
+ class Unit
7
+ class NotFoundError < StandardError; end
8
+
9
+ def initialize(name:, name_jp:, color:, idols:)
10
+ @name = name
11
+ @name_jp = name_jp
12
+ @color = color
13
+ @idols = idols
14
+ end
15
+
16
+ attr_reader :name, :name_jp, :color, :idols
17
+
18
+ class << self
19
+ def all
20
+ return @all unless @all.nil?
21
+
22
+ @all = YAML.load_file('./data/idol.yml').deep_symbolize_keys!
23
+ end
24
+
25
+ def names
26
+ all.keys
27
+ end
28
+
29
+ def find(name)
30
+ h = all[name]
31
+ raise(IdolNotFoundError) if h.nil?
32
+
33
+ new(**h)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShinyColors
4
+ VERSION = '0.2.1'
5
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shinycolors
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - iavivai
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'shinycolorsは「アイドルマスター シャイニーカラーズ」の情報をRubyで扱えるようにするためのgemです。
14
+
15
+ '
16
+ email:
17
+ - 18yukitaka@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/shinycolors.rb
23
+ - lib/shinycolors/idol.rb
24
+ - lib/shinycolors/unit.rb
25
+ - lib/shinycolors/version.rb
26
+ homepage: https://github.com/iavivai/shinycolors
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ homepage_uri: https://github.com/iavivai/shinycolors
31
+ source_code_uri: https://github.com/iavivai/shinycolors
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.5.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.1.2
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Rubyでシャニマスを扱えるようにするgem
51
+ test_files: []