al_bhed 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c71e1a60866ee27542c47acb126b450ffb900b5e7ac84fc2116a99f56d8680a8
4
- data.tar.gz: 1182ea4e576808351d355199534d8d710f60e832b4d849b9b227405cfdedc2d7
3
+ metadata.gz: d245f88436e0c19ae6ae174ed3c4243821d803254dfb08c7c31ab66fefa148ae
4
+ data.tar.gz: 5c3ee151f9b0dce5c2e538a8c25169ebd325f70f9aef2af1c9b87870cd6384a3
5
5
  SHA512:
6
- metadata.gz: 96c276a65d481770cfe03334db402b4281b0820479b1fd70a24759a72ced5ade1036d0da6d602753b6b36d7c787c64ee9ef51e7375c8fc1ad7b5d3cc14536c52
7
- data.tar.gz: e822bc4fbdbcc91a9e6323fd308301f6eddbba4b628b85d3b0b95150eab89f2198bebe376f26fab8d271f39063b4653b70166c3fbb51736bc2561d7cf81e0014
6
+ metadata.gz: 6e35f1be5c6e3e36e810f915f19e14f141091075e208b2df6baf6fcefd9cebcf92c0b9d50589e694e13008bf972856b114e1347d1ac5347f710595d2cd5ac1fb
7
+ data.tar.gz: 4e3ed4acdea159f90dc9bb80e7a93ea571cf5042caa855b5fb82a8d456503fa11e10f00ac2d2f3c8fc7bba8aa93c8a9593de52028a9c695ca072e5f6ceb98c1a
@@ -1,7 +1,12 @@
1
+ # v0.1.2
2
+ - add `String#from_albhed` method
3
+ - enabled to translate Japanese
4
+ - add README in Al Bhed
5
+
1
6
  # v0.1.1
2
7
  Edit CHANGELOG.md
3
8
 
4
9
  # v0.1.0
5
10
  First Release
6
11
 
7
- - add `to_albhed` method
12
+ - add `String#to_albhed` method
data/README.md CHANGED
@@ -1,3 +1,72 @@
1
+ # YmPrat
2
+
3
+ Dnyhcmydun vun Ym Prat myhkiyka eh VEHYM VYHDYCO Q
4
+
5
+ ## Ehcdymmydeuh
6
+
7
+ Ytt drec meha du ouin ybbmelydeuh'c Kasvema:
8
+
9
+ ```ruby
10
+ gem 'al_bhed'
11
+ ```
12
+
13
+ Yht drah aqalida:
14
+
15
+ $ bundle install
16
+
17
+ Un ehcdymm ed ouincamv yc:
18
+
19
+ $ gem install al_bhed
20
+
21
+ ## Icyka
22
+ ### Ev oui dnyhcmyda Ahkmecr ehdu Ym Prat...
23
+
24
+ ```ruby
25
+ "Hi, would you like to contribute to this gem?".to_albhed
26
+ # => "Re, fuimt oui mega du luhdnepida du drec kas?"
27
+ ```
28
+
29
+ ### Ev oui dnyhcmyda Ym Prat ehdu Ahkmecr...
30
+
31
+ ```ruby
32
+ "Lyh oui ihtancdyht sa?".from_albhed
33
+ # => "Can you understand me?"
34
+ ```
35
+
36
+ ### Ev oui ica Zybyhaca
37
+
38
+ ```ruby
39
+ "ファイナル・ファンタジー".to_albhed
40
+ # => "クァミハウ・クァンサギー"
41
+ ```
42
+
43
+ ```ruby
44
+ "ヨエマソセコ役シ立サハミkasベヌ。".from_albhed(hira: true)
45
+ # => "これはとても役に立たないgemです。"
46
+ ```
47
+
48
+ ## Tajamubsahd
49
+
50
+ Yvdan lralgehk uid dra nabu, nih `bin/setup` du ehcdymm tabahtahleac. Drah, nih `rake spec` du nih dra dacdc. Oui lyh ymcu nih `bin/console` vun yh ehdanyldeja bnusbd dryd femm ymmuf oui du aqbanesahd.
51
+
52
+ Du ehcdymm drec kas uhdu ouin mulym sylreha, nih `bundle exec rake install`. Du namayca y haf janceuh, ibtyda dra janceuh hispan eh `version.rb`, yht drah nih `bundle exec rake release`, frelr femm lnayda y ked dyk vun dra janceuh, bicr ked lussedc yht dykc, yht bicr dra `.gem` vema du [rubygems.org](https://rubygems.org).
53
+
54
+ ## Luhdnepidehk
55
+
56
+ Pik nabundc yht bimm naxiacdc yna famlusa uh KedRip yd https://github.com/HrsUed/al_bhed. Drec bnuzald ec ehdahtat du pa y cyva, famlusehk cbyla vun lummypunydeuh, yht luhdnepidunc yna aqbaldat du ytrana du dra [Luta uv Luhtild](https://github.com/HrsUed/al_bhed/blob/master/CODE_OF_CONDUCT.md).
57
+
58
+
59
+ ## Melahca
60
+
61
+ Dra kas ec yjyemypma yc ubah cuinla ihtan dra dansc uv dra [SED Melahca](https://opensource.org/licenses/MIT).
62
+
63
+ ## Luta uv Luhtild
64
+
65
+ Ajanouha ehdanyldehk eh dra YmPrat bnuzald'c lutapycac, eccia dnylganc, lryd nuusc yht syemehk mecdc ec aqbaldat du vummuf dra [luta uv luhtild](https://github.com/HrsUed/al_bhed/blob/master/CODE_OF_CONDUCT.md).
66
+
67
+
68
+ -----------------------
69
+
1
70
  # AlBhed
2
71
 
3
72
  Translator for Al Bhed language in FINAL FANTASY X
@@ -28,11 +97,22 @@ Or install it yourself as:
28
97
 
29
98
  ### If you translate Al Bhed into English...
30
99
 
31
- Sorry, it isn't implemented yet.
100
+ ```ruby
101
+ "Lyh oui ihtancdyht sa?".from_albhed
102
+ # => "Can you understand me?"
103
+ ```
32
104
 
33
105
  ### If you use Japanese...
34
106
 
35
- Sorry, it isn't implemented yet.
107
+ ```ruby
108
+ "ファイナル・ファンタジー".to_albhed
109
+ # => "クァミハウ・クァンサギー"
110
+ ```
111
+
112
+ ```ruby
113
+ "ヨエマソセコ役シ立サハミkasベヌ。".from_albhed(hira: true)
114
+ # => "これはとても役に立たないgemです。"
115
+ ```
36
116
 
37
117
  ## Development
38
118
 
@@ -42,7 +122,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
42
122
 
43
123
  ## Contributing
44
124
 
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/al_bhed. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/al_bhed/blob/master/CODE_OF_CONDUCT.md).
125
+ Bug reports and pull requests are welcome on GitHub at https://github.com/HrsUed/al_bhed. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/HrsUed/al_bhed/blob/master/CODE_OF_CONDUCT.md).
46
126
 
47
127
 
48
128
  ## License
@@ -51,4 +131,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
51
131
 
52
132
  ## Code of Conduct
53
133
 
54
- Everyone interacting in the AlBhed project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/al_bhed/blob/master/CODE_OF_CONDUCT.md).
134
+ Everyone interacting in the AlBhed project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/HrsUed/al_bhed/blob/master/CODE_OF_CONDUCT.md).
@@ -3,13 +3,19 @@ require "al_bhed/version"
3
3
  module AlBhed
4
4
  class Error < StandardError; end
5
5
 
6
- UPCASES = %w( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
7
- DOWNCASES = %w( a b c d e f g h i j k l m n o p q r s t u v w x y z )
8
- UPCASED_ALBHEDS = %w( Y P L T A V K R E Z G M S H U B X N C D I J F Q O W )
6
+ UPCASES = %w( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
7
+ UPCASED_ALBHEDS = %w( Y P L T A V K R E Z G M S H U B X N C D I J F Q O W )
8
+ DOWNCASES = %w( a b c d e f g h i j k l m n o p q r s t u v w x y z )
9
9
  DOWNCASED_ALBHEDS = %w( y p l t a v k r e z g m s h u b x n c d i j f q o w )
10
10
 
11
- class ::String
11
+ HIRA_KANA = %w( あ い う え お か き く け こ さ し す せ そ た ち つ て と な に ぬ ね の は ひ ふ へ ほ ま み む め も や ゆ よ ら り る れ ろ わ を ん )
12
+ KATA_KANA = %w( ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン )
13
+ HIRA_DAKUON = %w( が ぎ ぐ げ ご ざ じ ず ぜ ぞ だ ぢ づ で ど ば び ぶ べ ぼ ぱ ぴ ぷ ぺ ぽ )
14
+ KATA_DAKUON = %w( ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ )
15
+ KANA_ALBHEDS = %w( ワ ミ フ ネ ト ア チ ル テ ヨ ラ キ ヌ ヘ ホ サ ヒ ユ セ ソ ハ シ ス メ オ マ リ ク ケ ロ ヤ イ ツ レ コ タ ヲ モ ナ ニ ウ エ ノ カ ム ン )
16
+ DAKUON_ALBHEDS = %w( ダ ジ ヅ デ ゾ バ ギ ブ ゲ ボ ガ ビ グ ベ ゴ ザ ヂ ズ ゼ ド プ ペ パ ポ ピ )
12
17
 
18
+ class ::String
13
19
  # Translate into Al Bhed
14
20
  #
15
21
  # Example:
@@ -18,17 +24,78 @@ module AlBhed
18
24
  #
19
25
  # Arguments:
20
26
  # nothing
21
-
22
27
  def to_albhed
23
28
  self.chars.inject("") do |results, c|
24
- if idx = DOWNCASES.index(c)
25
- results << DOWNCASED_ALBHEDS[idx]
26
- elsif idx = UPCASES.index(c)
27
- results << UPCASED_ALBHEDS[idx]
29
+ if latin?(c)
30
+ results << from_english_to_albhed(c)
31
+ else
32
+ results << from_japanese_to_albhed(c)
33
+ end
34
+ end
35
+ end
36
+
37
+ # Translate Al Bhed into English
38
+ #
39
+ # Example:
40
+ # >> "Re!".from_albhed
41
+ # => "Hi!"
42
+ #
43
+ # Arguments:
44
+ # hira: (Boolean)
45
+ def from_albhed(hira: false)
46
+ self.chars.inject("") do |results, c|
47
+ if latin?(c)
48
+ results << from_albhed_to_english(c)
28
49
  else
29
- results << c
50
+ results << from_albhed_to_japanese(c, hira: hira)
30
51
  end
31
52
  end
32
53
  end
54
+
55
+ private
56
+
57
+ def latin?(c)
58
+ ("a" .. "z").include?(c) || ("A" .. "Z").include?(c)
59
+ end
60
+
61
+ def from_english_to_albhed(c)
62
+ if idx = DOWNCASES.index(c)
63
+ DOWNCASED_ALBHEDS[idx]
64
+ elsif idx = UPCASES.index(c)
65
+ UPCASED_ALBHEDS[idx]
66
+ else
67
+ c
68
+ end
69
+ end
70
+
71
+ def from_albhed_to_english(c)
72
+ if idx = DOWNCASED_ALBHEDS.index(c)
73
+ DOWNCASES[idx]
74
+ elsif idx = UPCASED_ALBHEDS.index(c)
75
+ UPCASES[idx]
76
+ else
77
+ c
78
+ end
79
+ end
80
+
81
+ def from_japanese_to_albhed(c)
82
+ if idx = HIRA_KANA.index(c) || KATA_KANA.index(c)
83
+ KANA_ALBHEDS[idx]
84
+ elsif idx = HIRA_DAKUON.index(c) || KATA_DAKUON.index(c)
85
+ DAKUON_ALBHEDS[idx]
86
+ else
87
+ c
88
+ end
89
+ end
90
+
91
+ def from_albhed_to_japanese(c, hira: false)
92
+ if idx = KANA_ALBHEDS.index(c)
93
+ hira ? HIRA_KANA[idx] : KATA_KANA[idx]
94
+ elsif idx = DAKUON_ALBHEDS.index(c)
95
+ hira ? HIRA_DAKUON[idx] : KATA_DAKUON[idx]
96
+ else
97
+ c
98
+ end
99
+ end
33
100
  end
34
101
  end
@@ -1,3 +1,3 @@
1
1
  module AlBhed
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: al_bhed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - HrsUed
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-29 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Translator for Al Bhed language in FINAL FANTASY X
14
14
  email: