Class: Beckett::Node::Element

Inherits:
Base
  • Object
show all
Defined in:
lib/beckett/node/element.rb

Direct Known Subclasses

Article, Br, Codeblock, Header, Section

Instance Attribute Summary

Attributes inherited from Base

#children, #node, #position

Instance Method Summary collapse

Methods inherited from Base

#<<, #initialize, #inspect, #to_s

Constructor Details

This class inherits a constructor from Beckett::Node::Base

Instance Method Details

#to_hObject



3
4
5
6
7
8
9
10
11
# File 'lib/beckett/node/element.rb', line 3

def to_h
  {}.tap do |element|
    element[:node_name]  = node_name
    element[:node_type]  = node_type
    # NOTE: might add attributes as `nil` or empty Hash at a later date...
    element[:attributes] = node_attributes if node_attributes
    element[:children]   = children.map(&:to_h)
  end
end