Class: CraftBook::NBT::StringTag
- Defined in:
- lib/craftbook/nbt/string_tag.rb
Overview
Represents a UTF-8 encoded string.
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
-
#value ⇒ String
The value of the tag.
Attributes inherited from Tag
Instance Method Summary collapse
-
#initialize(name, value = '') ⇒ StringTag
constructor
Creates a new instance of the StringTag 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
#initialize(name, value = '') ⇒ StringTag
Creates a new instance of the CraftBook::NBT::StringTag class.
19 20 21 |
# File 'lib/craftbook/nbt/string_tag.rb', line 19 def initialize(name, value = '') super(TYPE_STRING, name, value) end |
Instance Attribute Details
#value ⇒ String
Returns the value of the tag.
|
# File 'lib/craftbook/nbt/string_tag.rb', line 10
|
Instance Method Details
#stringify ⇒ String
Returns the NBT tag as an SNBT string.
35 36 37 |
# File 'lib/craftbook/nbt/string_tag.rb', line 35 def stringify "#{snbt_prefix}\"#{@value}\"" end |
#to_s ⇒ String
Returns the NBT tag as a formatted and human-readable string.
29 30 31 |
# File 'lib/craftbook/nbt/string_tag.rb', line 29 def to_s "TAG_String(#{@name ? "\"#{@name}\"" : 'None'}): \"#{@value}\"" end |