Class: JsonCanvas::TextNode

Inherits:
GenericNode show all
Defined in:
lib/json_canvas/node.rb

Instance Attribute Summary collapse

Attributes inherited from GenericNode

#color, #height, #id, #width, #x, #y

Instance Method Summary collapse

Methods inherited from GenericNode

#default_height, #default_width, #to_hash_common

Constructor Details

#initialize(**kwargs) ⇒ TextNode

Returns a new instance of TextNode.



39
40
41
42
43
# File 'lib/json_canvas/node.rb', line 39

def initialize(**kwargs)
  super(**kwargs)
  @type = "text"
  @text = kwargs[:text] || ""
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



37
38
39
# File 'lib/json_canvas/node.rb', line 37

def text
  @text
end

#typeObject

Returns the value of attribute type.



37
38
39
# File 'lib/json_canvas/node.rb', line 37

def type
  @type
end

Instance Method Details

#to_hashObject



45
46
47
48
49
# File 'lib/json_canvas/node.rb', line 45

def to_hash
  h = to_hash_common(type)
  h["text"] = text
  h
end