tclog 0.1.1 → 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.
Files changed (5) hide show
  1. data/README.mkd +1 -1
  2. data/VERSION +1 -1
  3. data/lib/tclog.rb +56 -16
  4. data/tclog.gemspec +2 -2
  5. metadata +4 -4
data/README.mkd CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  The MIT License
19
19
 
20
- (c) Shota Fukumori (sora_h) 2010-
20
+ (c) Shota Fukumori (sora_h) 2010
21
21
 
22
22
  Permission is hereby granted, free of charge, to any person obtaining a copy
23
23
  of this software and associated documentation files (the "Software"), to deal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -1,32 +1,72 @@
1
1
  # = TCLog
2
2
  # Author:: Shota Fukumori (sora_h)
3
- # Copyright:: (c) Shota Fukumori (sora_h) 2010- w/ mit license
3
+ # Copyright:: (c) Shota Fukumori (sora_h) 2010 w/ mit license
4
4
  # License:: MIT License; License terms written in README.mkd
5
5
  #
6
6
  # This library helps TC:E stats parsing.
7
7
  #
8
8
  module TCLog
9
9
  class Game
10
+ class PlayerArray < Hash
11
+ def initialize(*args) # :nodoc:
12
+ @ary = []
13
+ super *args
14
+ end
15
+
16
+ # [x]
17
+ # String or Integer.
18
+ # String finds player from name, Integer finds player from index.
19
+ #
20
+ # Get Player object.
21
+ def [](x)
22
+ if x.kind_of?(Integer)
23
+ self[@ary[x]] if @ary[x]
24
+ else
25
+ super x
26
+ end
27
+ end
28
+
29
+ # [a]
30
+ # Player's name.
31
+ # [b]
32
+ # TCLog::Player object.
33
+ #
34
+ # Add Player with name.
35
+ def []=(a,b)
36
+ @ary << a
37
+ super a,b
38
+ end
39
+
40
+ # [player]
41
+ # TCLog::Player object.
42
+ #
43
+ # Add Player.
44
+ def <<(player)
45
+ @ary << player.name
46
+ self[player.name] = player
47
+ self
48
+ end
49
+
50
+ # yield each player
51
+ def each # :yield: player
52
+ @ary.each do |name|
53
+ yield self[name]
54
+ end
55
+ end
56
+
57
+ def inspect # :nodoc:
58
+ @ary.map do |name|
59
+ self[name]
60
+ end
61
+ end
62
+ end
10
63
  def initialize(orders = [], gametype = :obj) # :nodoc:
11
64
  @orders = orders
12
65
  @gametype = gametype
13
66
  @rounds = []
14
67
  @round_n = -1
15
68
  @round_r = -1
16
- @players = {}
17
- class << @players
18
- def [](x)
19
- if x.kind_of?(Integer)
20
- self.map{|v|v}[x]
21
- else
22
- super x
23
- end
24
- end
25
-
26
- def each
27
- super &(Proc.new{|k,v| yield v })
28
- end
29
- end
69
+ @players = PlayerArray.new
30
70
  end
31
71
 
32
72
 
@@ -46,7 +86,7 @@ module TCLog
46
86
  end
47
87
 
48
88
  def add_player(name) # :nodoc:
49
- @players[name] = Player.new(name)
89
+ @players << Player.new(name)
50
90
  if 0 <= @round_r
51
91
  @players[name].push_result(@round_r)
52
92
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tclog}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shota Fukumori"]
12
- s.date = %q{2010-12-25}
12
+ s.date = %q{2010-12-27}
13
13
  s.description = %q{Parser for etconsole.log of TrueCombat:Elite (TC:E)}
14
14
  s.email = %q{sorah@tubusu.net}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Shota Fukumori
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-25 00:00:00 +09:00
17
+ date: 2010-12-27 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies: []
20
20