class Bromlife::Element
Attributes
Public Class Methods
Source
# File lib/bromlife.rb, line 55 def initialize(label:, parent:) @label = label @parent = parent @children = [] end
Public Instance Methods
Source
# File lib/bromlife.rb, line 65 def deconstruct_keys(*_keys) # TODO: optimize with keys param. { label: @label, children: @children } end
Source
# File lib/bromlife.rb, line 70 def inspect "#<Bromlife::Element @label=#{ @label.inspect } @children=#{ @children.inspect }>" end
Source
# File lib/bromlife.rb, line 77 def to_h { :label => @label, :children => @children.map { |child| child.is_a?(String) ? child : child.to_h } } end
This recursively transforms into the Ruby data represented by Array, Hash, and String.