Class: JsonCanvas::TextNode
- Inherits:
-
GenericNode
- Object
- GenericNode
- JsonCanvas::TextNode
- Defined in:
- lib/json_canvas/node.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from GenericNode
#color, #height, #id, #width, #x, #y
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ TextNode
constructor
A new instance of TextNode.
- #to_hash ⇒ Object
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
#text ⇒ Object
Returns the value of attribute text.
37 38 39 |
# File 'lib/json_canvas/node.rb', line 37 def text @text end |
#type ⇒ Object
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_hash ⇒ Object
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 |