Class: JsonCanvas::FileNode

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



55
56
57
58
59
60
# File 'lib/json_canvas/node.rb', line 55

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

Instance Attribute Details

#fileObject

Returns the value of attribute file.



53
54
55
# File 'lib/json_canvas/node.rb', line 53

def file
  @file
end

#subpathObject

Returns the value of attribute subpath.



53
54
55
# File 'lib/json_canvas/node.rb', line 53

def subpath
  @subpath
end

#typeObject

Returns the value of attribute type.



53
54
55
# File 'lib/json_canvas/node.rb', line 53

def type
  @type
end

Instance Method Details

#to_hashObject



62
63
64
65
66
67
# File 'lib/json_canvas/node.rb', line 62

def to_hash
  h = to_hash_common(type)
  h["file"] = file
  h["subpath"] = subpath if subpath
  h
end