battle_pet 0.2.1 → 0.2.2

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.
data/README.md CHANGED
@@ -6,7 +6,7 @@ This is a gem to parse the info from WoW BattlePet API.
6
6
 
7
7
  ## Usage
8
8
 
9
- ```
9
+ ```ruby
10
10
  require 'battle_pet'
11
11
  pet = BattlePet.new(39)
12
12
  ```
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ class BattlePet::Translator
3
+
4
+ def initialize(locale)
5
+ @locale = locale
6
+ end
7
+
8
+ def colon
9
+ case @locale
10
+ when :cn then ':'
11
+ when :tw then ':'
12
+ else ': '
13
+ end
14
+ end
15
+
16
+ def cost
17
+ case @locale
18
+ when :us, :eu then 'Cost'
19
+ when :cn then '价格'
20
+ when :tw then '花費'
21
+ when :kr then '비용'
22
+ end
23
+ end
24
+ end
data/lib/battle_pet.rb CHANGED
@@ -60,8 +60,9 @@ class BattlePet
60
60
 
61
61
  def self.parse_source(str_source, locale)
62
62
  hash_source = {}
63
+ translator = Translator.new(locale)
63
64
  str_source.split(/\n+/).each do |line|
64
- match_data = line.match(": ")
65
+ match_data = line.match(translator.colon)
65
66
  k = match_data.pre_match
66
67
  v = match_data.post_match.gsub(/\(\d+\)/, '').strip
67
68
  hash_source[k] = v
@@ -72,3 +73,4 @@ end
72
73
 
73
74
  require 'battle_pet/type'
74
75
  require 'battle_pet/ability'
76
+ require 'battle_pet/translator'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: battle_pet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,6 +20,7 @@ files:
20
20
  - lib/battle_pet.rb
21
21
  - lib/battle_pet/ability.rb
22
22
  - lib/battle_pet/type.rb
23
+ - lib/battle_pet/translator.rb
23
24
  - test/data/mechanical_squirrel_cn.json
24
25
  - test/data/mechanical_squirrel_us.json
25
26
  - test/test_battle_pet.rb