Added to_h (to hash) method to Vector, Text now tries to convert given text to string instead of assuming it is a string

This commit is contained in:
2019-05-03 13:52:01 -05:00
parent f489ad162f
commit db1a0683e2
2 changed files with 5 additions and 1 deletions

View File

@@ -160,5 +160,9 @@ module CyberarmEngine
def to_s def to_s
"X: #{@x}, Y: #{@y}, Z: #{@z}, Weight: #{@weight}" "X: #{@x}, Y: #{@y}, Z: #{@z}, Weight: #{@weight}"
end end
def to_h
{x: @x, y: @y, z: @z, weight: @weight}
end
end end
end end

View File

@@ -6,7 +6,7 @@ module CyberarmEngine
attr_reader :text, :textobject attr_reader :text, :textobject
def initialize(text, options={}) def initialize(text, options={})
@text = text || "" @text = text.to_s || ""
@options = options @options = options
@size = options[:size] || 18 @size = options[:size] || 18
@font = options[:font] || "sans-serif"#Gosu.default_font_name @font = options[:font] || "sans-serif"#Gosu.default_font_name