nbtfile 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +71 -23
  2. data/VERSION +1 -1
  3. data/lib/nbtfile.rb +1 -2
  4. metadata +7 -3
@@ -13,16 +13,16 @@ http://www.minecraft.net/docs/NBT.txt
13
13
 
14
14
  The NBT data model has ten different data types:
15
15
 
16
- - 8-bit signed integers (Tag_Byte)
17
- - 16-bit signed integers (Tag_Short)
18
- - 32-bit signed integers (Tag_Int)
19
- - 64-bit signed integers (Tag_Long)
20
- - 32-bit floating-point numbers (Tag_Float)
21
- - 64-bit floating-point numbers (Tag_Double)
22
- - UTF-8 strings (Tag_String)
23
- - raw byte strings (Tag_Byte_Array)
24
- - homogenous lists (Tag_List)
25
- - compound structures (Tag_Compound)
16
+ * 8-bit signed integers (Tag_Byte)
17
+ * 16-bit signed integers (Tag_Short)
18
+ * 32-bit signed integers (Tag_Int)
19
+ * 64-bit signed integers (Tag_Long)
20
+ * 32-bit floating-point numbers (Tag_Float)
21
+ * 64-bit floating-point numbers (Tag_Double)
22
+ * UTF-8 strings (Tag_String)
23
+ * raw byte sequences (Tag_Byte_Array)
24
+ * homogenous lists (Tag_List)
25
+ * compound structures (Tag_Compound)
26
26
 
27
27
  Compound structures (Tag_Compound) are unordered
28
28
  collections where each item ("tag") has a name associated
@@ -44,6 +44,66 @@ Tag_End, but this is not supported in practice.
44
44
  The top level of an NBT file must be a single-element
45
45
  compound structure.
46
46
 
47
+ == Interface
48
+
49
+ == Low-level API
50
+
51
+ The low-level API deals directly in NBT tokens, which are represented by eleven types:
52
+
53
+ * NBTFile::Tokens::TAG_End
54
+ * NBTFile::Tokens::TAG_Byte
55
+ * NBTFile::Tokens::TAG_Short
56
+ * NBTFile::Tokens::TAG_Long
57
+ * NBTFile::Tokens::TAG_Float
58
+ * NBTFile::Tokens::TAG_Double
59
+ * NBTFile::Tokens::TAG_Byte_Array
60
+ * NBTFile::Tokens::TAG_String
61
+ * NBTFile::Tokens::TAG_List
62
+ * NBTFile::Tokens::TAG_Compound
63
+
64
+ Their constructors each take two arguments: <code>name</code> and <code>value</code>,
65
+ which are also exposed by similarly-named accessors. Most of these tokens represent
66
+ simple values, but TAG_List and TAG_Compound introduce the beginning of a list and a
67
+ compound structure, and TAG_End terminates either one.
68
+
69
+ The <code>name</code> field supplies the field name when the token is part of a compound
70
+ structure, and is ignored when it is part of a list.
71
+
72
+ For most token types, <code>value</code> represents the value of the token. For TAG_List
73
+ it represents the type of the list. It is ignored for compound structures.
74
+
75
+ === NBTFile.tokenize
76
+
77
+ === NBTFile.emit
78
+
79
+ == High-level API
80
+
81
+ Much of the high-level API deals in higher-level data types from the NBTFile::Types module.
82
+
83
+ There are eight "primitive" types with <code>value</code> fields which reflect their native Ruby values:
84
+
85
+ * NBTFile::Types::Byte
86
+ * NBTFile::Types::Short
87
+ * NBTFile::Types::Int
88
+ * NBTFile::Types::Long
89
+ * NBTFile::Types::Float
90
+ * NBTFile::Types::Double
91
+ * NBTFile::Types::ByteArray
92
+ * NBTFile::Types::String
93
+
94
+ There are also two "complex" types which reflect NBT lists and compound structures:
95
+
96
+ * NBTFile::Types::List - an Array-like class corresponding to an NBT list
97
+ * NBTFile::Types::Compound - a Hash-like class correspodning to an NBT compound structure
98
+
99
+ === NBTFile.read
100
+
101
+ === NBTFile.write
102
+
103
+ === NBTFile.load
104
+
105
+ === NBTFile.transcode_to_yaml
106
+
47
107
  == Syntax
48
108
 
49
109
  NBT files are gzip-compressed; the structure of the
@@ -115,18 +175,6 @@ ABNF (see RFC 5234).
115
175
  TAG-LIST = %x09
116
176
  TAG-COMPOUND = %x0a
117
177
 
118
- == Interface
119
-
120
- == Low-level API
121
-
122
- === NBTFile.tokenize
123
-
124
- === NBTFile.emit
125
-
126
- == High-level API
127
-
128
- === NBTFile.load
129
-
130
178
  == Note on Patches/Pull Requests
131
179
 
132
180
  * Fork the project.
@@ -139,4 +187,4 @@ ABNF (see RFC 5234).
139
187
 
140
188
  == Copyright
141
189
 
142
- Copyright (c) 2010 MenTaLguY. See LICENSE for details.
190
+ Copyright (c) 2010-2011 MenTaLguY. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -24,7 +24,6 @@
24
24
  require 'zlib'
25
25
  require 'stringio'
26
26
  require 'yaml'
27
- require 'enumerator'
28
27
 
29
28
  class String #:nodoc: all
30
29
  begin
@@ -1008,7 +1007,7 @@ module Types
1008
1007
  @key_order.each { |k| yield k, @hash[k] }
1009
1008
  self
1010
1009
  else
1011
- Enumerable::Enumerator.new(self, :each)
1010
+ @key_order.each
1012
1011
  end
1013
1012
  end
1014
1013
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nbtfile
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 1
8
+ - 2
8
9
  - 0
9
- version: 0.1.0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - MenTaLguY
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-02-09 00:00:00 -08:00
18
+ date: 2011-02-13 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 2
30
32
  - 0
@@ -68,6 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
70
  requirements:
69
71
  - - ">="
70
72
  - !ruby/object:Gem::Version
73
+ hash: 3
71
74
  segments:
72
75
  - 0
73
76
  version: "0"
@@ -76,6 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
79
  requirements:
77
80
  - - ">="
78
81
  - !ruby/object:Gem::Version
82
+ hash: 3
79
83
  segments:
80
84
  - 0
81
85
  version: "0"