Class: CraftBook::NBT::ByteTag
- Defined in:
- lib/craftbook/nbt/byte_tag.rb
Overview
A tag type representing an 8-bit signed integer in the range of -128
and 127
inclusive.
Constant Summary collapse
- MIN =
The minimum permissible value for this type.
-0x80
- MAX =
The maximum permissible value for this type.
0x7F
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
-
#value ⇒ Numeric, Boolean
The value of the tag.
Attributes inherited from Tag
Instance Method Summary collapse
-
#bool ⇒ Boolean
The value of the tag as boolean.
-
#initialize(name, value = 0) ⇒ ByteTag
constructor
Creates a new instance of the DoubleTag 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 ValueTag
Methods inherited from Tag
parse, #pretty, #pretty_print, #to_h, #to_json
Constructor Details
Instance Attribute Details
#value ⇒ Numeric, Boolean
The value of the tag. Values of true
and false
will be converted to 1
and 0
respectfully.
|
# File 'lib/craftbook/nbt/byte_tag.rb', line 18
|
Instance Method Details
#bool ⇒ Boolean
Returns the value of the tag as boolean.
44 45 46 |
# File 'lib/craftbook/nbt/byte_tag.rb', line 44 def bool @value != 0 end |
#stringify ⇒ String
Returns the NBT tag as an SNBT string.
56 57 58 |
# File 'lib/craftbook/nbt/byte_tag.rb', line 56 def stringify "#{snbt_prefix}#{@value}B" end |
#to_s ⇒ String
Returns the NBT tag as a formatted and human-readable string.
50 51 52 |
# File 'lib/craftbook/nbt/byte_tag.rb', line 50 def to_s "TAG_Byte(#{@name ? "\"#{@name}\"" : 'None'}): #{@value}" end |