Class: CraftBook::NBT::ValueTag Abstract

Inherits:
Tag
  • Object
show all
Defined in:
lib/craftbook/nbt/value_tag.rb

Overview

This class is abstract.

Abstract base class for tags that can contain a single primitive value.

Direct Known Subclasses

ByteTag, DoubleTag, FloatTag, IntTag, LongTag, ShortTag, StringTag

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 collapse

Attributes inherited from Tag

#name, #type

Instance Method Summary collapse

Methods inherited from Tag

parse, #pretty, #pretty_print, #stringify, #to_json

Constructor Details

#initialize(type, name, value) ⇒ ValueTag

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

Parameters:

  • name (String, NilClass)

    The name of the tag, or nil when unnamed.

  • value (Object)

    The value of the tag.



21
22
23
24
# File 'lib/craftbook/nbt/value_tag.rb', line 21

def initialize(type, name, value)
  super(type, name)
  self.value = value
end

Instance Attribute Details

#valueObject



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

def value
  @value
end

Instance Method Details

#to_hHash{Symbol => Object}

Returns the hash-representation of this object.

Returns:

  • (Hash{Symbol => Object})

    the hash-representation of this object.



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

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