Skip to content

Commit

Permalink
prepare for file writing. update to work with ruby 1.9.2. No longer w…
Browse files Browse the repository at this point in the history
…orks with 1.8, and won't in the future.
  • Loading branch information
mpd committed Sep 22, 2010
1 parent be40da7 commit 8caf25d
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/nbt/tag/byte.rb
Expand Up @@ -17,7 +17,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Byte#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/byte_array.rb
Expand Up @@ -18,7 +18,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Byte_Array#{@name ? "(\"#{@name}\")" : ''}: [#{@payload.length} bytes]"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/nbt/tag/compound.rb
Expand Up @@ -8,7 +8,7 @@ def initialize(io, named = true)
@tag_names = []
read_name(io) if named

until (last_byte = io.read(1)[0]) == NBT::Tag::End.type_id
until (last_byte = io.read(1).bytes.first) == NBT::Tag::End.type_id
klass = tag_type_to_class(last_byte)
i = klass.new(io, true)
add_tag(i)
Expand All @@ -30,7 +30,7 @@ def to_s(indent = 0)
ret
end

def to_nbt_string
def to_nbt_string(named = true)

end

Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/double.rb
Expand Up @@ -17,7 +17,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Double#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/end.rb
Expand Up @@ -15,7 +15,7 @@ def to_s(indent = 0)
''
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/float.rb
Expand Up @@ -17,7 +17,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Float#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/int.rb
Expand Up @@ -17,7 +17,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Int#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/nbt/tag/list.rb
Expand Up @@ -7,7 +7,7 @@ def initialize(io, named = true)
@payload = []
read_name(io) if named

tag_id = io.read(1)[0].to_i
tag_id = io.read(1).bytes.first.to_i
@tag_type = NBT::Tag.tag_type_to_class(tag_id)
len = ::BinData::Int32be.new.read(io).value
len.times do
Expand All @@ -30,7 +30,7 @@ def to_s(indent = 0)
ret
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/long.rb
Expand Up @@ -17,7 +17,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Long#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/nbt/tag/short.rb
Expand Up @@ -17,7 +17,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_Short#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/nbt/tag/string.rb
Expand Up @@ -6,7 +6,7 @@ class String
def initialize(io, named = true)
read_name(io) if named

l = io.read(2).unpack('n').first
l = ::BinData::Int16be.new.read(io).value.to_i

@payload = io.read(l)
end
Expand All @@ -19,7 +19,7 @@ def to_s(indent = 0)
(' ' * indent) + "TAG_String#{@name ? "(\"#{@name}\")" : ''}: #{@payload}"
end

def to_nbt_string
def to_nbt_string(named = true)

end
end
Expand Down
26 changes: 13 additions & 13 deletions script.rb
@@ -1,35 +1,35 @@
require 'bundler'
Bundler.require :default

require 'lib/nbt'
require File.expand_path('./lib/nbt', File.dirname(__FILE__))
require 'zlib'

# Strangely, both test files have an extra null at the end of them, which would be a
# separate TAG_End if it were allowed.

@compound = nil

#Zlib::GzipReader.open('test.nbt') do |f|
# # ostensibly this will always be a single TAG_Compound, per the spec
# last_byte = f.read(1)[0]
# klass = NBT::Tag.tag_type_to_class(last_byte)
#
# @compound = klass.new(f, true)
#end
#
#puts @compound.to_s
#puts
Zlib::GzipReader.open('doc/test.nbt') do |f|
# ostensibly this will always be a single TAG_Compound, per the spec
last_byte = f.read(1).bytes.first
klass = NBT::Tag.tag_type_to_class(last_byte)

@compound = klass.new(f, true)
end

puts @compound.to_s
puts

Zlib::GzipReader.open('doc/bigtest.nbt') do |f|
# ostensibly this will always be a single TAG_Compound, per the spec
last_byte = f.read(1)[0]
last_byte = f.read(1).bytes.first
klass = NBT::Tag.tag_type_to_class(last_byte)

@compound = klass.new(f, true)
end

puts @compound.to_s

#puts @compound.find_tag('Test')
puts @compound.find_tag('Test')
puts @compound.find_tags(/(?:byte|int)Test/)
puts @compound.find_tags 'intasdf'

0 comments on commit 8caf25d

Please sign in to comment.