Class: JsonCanvas::LinkNode

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) ⇒ LinkNode

Returns a new instance of LinkNode.



73
74
75
76
77
# File 'lib/json_canvas/node.rb', line 73

def initialize(**kwargs)
  super(**kwargs)
  @type = "link"
  @url = kwargs[:url] || "https://www.ruby-lang.org"
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



71
72
73
# File 'lib/json_canvas/node.rb', line 71

def type
  @type
end

#urlObject

Returns the value of attribute url.



71
72
73
# File 'lib/json_canvas/node.rb', line 71

def url
  @url
end

Instance Method Details

#to_hashObject



79
80
81
82
83
# File 'lib/json_canvas/node.rb', line 79

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