Class: CraftBook::NBT::FloatTag
- Defined in:
- lib/craftbook/nbt/float_tag.rb
Overview
Represents a IEEE-754 single-precision floating point number (NaN possible).
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 ⇒ Numeric
The value of the tag.
Attributes inherited from Tag
Instance Method Summary collapse
-
#initialize(name, value = 0.0) ⇒ FloatTag
constructor
A new instance of FloatTag.
-
#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 = 0.0) ⇒ FloatTag
Returns a new instance of FloatTag.
14 15 16 |
# File 'lib/craftbook/nbt/float_tag.rb', line 14 def initialize(name, value = 0.0) super(TYPE_FLOAT, name, value) end |
Instance Attribute Details
#value ⇒ Numeric
Returns the value of the tag.
14 15 16 |
# File 'lib/craftbook/nbt/float_tag.rb', line 14 def initialize(name, value = 0.0) super(TYPE_FLOAT, name, value) end |
Instance Method Details
#stringify ⇒ String
Returns the NBT tag as an SNBT string.
30 31 32 |
# File 'lib/craftbook/nbt/float_tag.rb', line 30 def stringify "#{snbt_prefix}#{@value}F" end |
#to_s ⇒ String
Returns the NBT tag as a formatted and human-readable string.
24 25 26 |
# File 'lib/craftbook/nbt/float_tag.rb', line 24 def to_s "TAG_Float(#{@name ? "\"#{@name}\"" : 'None'}): #{@value}" end |