Class: CraftBook::NBT::ByteArrayTag
- Inherits:
-
EnumerableTag
- Object
- Tag
- EnumerableTag
- CraftBook::NBT::ByteArrayTag
- Defined in:
- lib/craftbook/nbt/byte_array_tag.rb
Overview
Represents a contiguous collection of signed 8-bit integers in the range of -128
to 127
inclusive.
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) ⇒ ByteArrayTag
constructor
Creates a new instance of the ByteArrayTag class.
-
#stringify ⇒ String
The NBT tag as an SNBT string.
-
#to_h ⇒ Hash{Symbol => Object}
The hash-representation of this object.
-
#to_s ⇒ String
The NBT tag as a formatted and human-readable string.
Methods inherited from EnumerableTag
#[], #[]=, #each, #push, #size
Methods inherited from Tag
parse, #pretty, #pretty_print, #to_json
Constructor Details
#initialize(name, *values) ⇒ ByteArrayTag
Creates a new instance of the CraftBook::NBT::ByteArrayTag class.
14 15 16 |
# File 'lib/craftbook/nbt/byte_array_tag.rb', line 14 def initialize(name, *values) super(TYPE_BYTE_ARRAY, name, values) end |
Instance Method Details
#stringify ⇒ String
Returns the NBT tag as an SNBT string.
32 33 34 |
# File 'lib/craftbook/nbt/byte_array_tag.rb', line 32 def stringify "#{snbt_prefix}[B;#{to_a.join(',')}]" end |
#to_h ⇒ Hash{Symbol => Object}
Returns the hash-representation of this object.
20 21 22 |
# File 'lib/craftbook/nbt/byte_array_tag.rb', line 20 def to_h { name: @name, type: @type, values: @values } end |
#to_s ⇒ String
Returns the NBT tag as a formatted and human-readable string.
26 27 28 |
# File 'lib/craftbook/nbt/byte_array_tag.rb', line 26 def to_s "TAG_Byte_Array(#{@name ? "\"#{@name}\"" : 'None'}): #{size} #{size == 1 ? 'item' : 'items'}" end |