Class: CraftBook::NBT::LongArrayTag

Inherits:
EnumerableTag show all
Defined in:
lib/craftbook/nbt/long_array_tag.rb

Overview

cRepresents a contiguous collection of signed 64-bit integers in the range of -9223372036854775808 and 9223372036854775807 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

#name, #type

Instance Method Summary collapse

Methods inherited from EnumerableTag

#[], #[]=, #each, #push, #size

Methods inherited from Tag

parse, #pretty, #pretty_print, #to_json

Constructor Details

#initialize(name, *values) ⇒ LongArrayTag

Creates a new instance of the CraftBook::NBT::LongArrayTag class.

Parameters:

  • name (String, NilClass)

    The name of the tag, or nil when unnamed.

  • values (Array<Numeric>)

    Zero or more values to add during initialization.



14
15
16
# File 'lib/craftbook/nbt/long_array_tag.rb', line 14

def initialize(name, *values)
  super(TYPE_LONG_ARRAY, name, *values)
end

Instance Method Details

#stringifyString

Returns the NBT tag as an SNBT string.

Returns:

  • (String)

    the NBT tag as an SNBT string.



32
33
34
# File 'lib/craftbook/nbt/long_array_tag.rb', line 32

def stringify
  "#{snbt_prefix}[L;#{to_a.join(',')}]"
end

#to_hHash{Symbol => Object}

Returns the hash-representation of this object.

Returns:

  • (Hash{Symbol => Object})

    the hash-representation of this object.



20
21
22
# File 'lib/craftbook/nbt/long_array_tag.rb', line 20

def to_h
  { name: @name, type: @type, values: @values }
end

#to_sString

Returns the NBT tag as a formatted and human-readable string.

Returns:

  • (String)

    the NBT tag as a formatted and human-readable string.



26
27
28
# File 'lib/craftbook/nbt/long_array_tag.rb', line 26

def to_s
  "TAG_Long_Array(#{@name ? "\"#{@name}\"" : 'None'}): #{size} #{size == 1 ? 'item' : 'items'}"
end