Class: CraftBook::NBT::CompoundTag
- Inherits:
-
ContainerTag
- Object
- Tag
- EnumerableTag
- ContainerTag
- CraftBook::NBT::CompoundTag
- Defined in:
- lib/craftbook/nbt/compound_tag.rb
Overview
Represents a collection of named tags, order not guaranteed.
Constant Summary
Constants inherited from Tag
Tag::TYPE_BYTE, Tag::TYPE_BYTE_ARRAY, Tag::TYPE_COMPOUND, Tag::TYPE_DOUBLE, Tag::TYPE_END, Tag::TYPE_FLOAT, Tag::TYPE_INT, Tag::TYPE_INT_ARRAY, Tag::TYPE_LIST, Tag::TYPE_LONG, Tag::TYPE_LONG_ARRAY, Tag::TYPE_SHORT, Tag::TYPE_STRING
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary collapse
-
#initialize(name, *values) ⇒ CompoundTag
constructor
Creates a new instance of the CompoundTag class.
-
#stringify ⇒ String
The NBT tag as an SNBT string.
-
#to_s ⇒ String
The NBT tag as a formatted and human-readable string.
Methods inherited from ContainerTag
Methods inherited from EnumerableTag
#[], #[]=, #each, #push, #size, #to_h
Methods inherited from Tag
parse, #pretty, #pretty_print, #to_h, #to_json
Constructor Details
#initialize(name, *values) ⇒ CompoundTag
Creates a new instance of the CraftBook::NBT::CompoundTag class.
15 16 17 |
# File 'lib/craftbook/nbt/compound_tag.rb', line 15 def initialize(name, *values) super(TYPE_COMPOUND, name, *values) end |
Instance Method Details
#stringify ⇒ String
Returns the NBT tag as an SNBT string.
27 28 29 |
# File 'lib/craftbook/nbt/compound_tag.rb', line 27 def stringify "{#{snbt_prefix}{#{map(&:stringify).join(',')}}" end |
#to_s ⇒ String
Returns the NBT tag as a formatted and human-readable string.
21 22 23 |
# File 'lib/craftbook/nbt/compound_tag.rb', line 21 def to_s "TAG_Compound(#{@name ? "\"#{@name}\"" : 'None'}): #{size} #{size == 1 ? 'child' : 'children'}" end |