class Beckett::Node::Element
Public Instance Methods
to_h()
click to toggle source
# 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
Private Instance Methods
node_attributes()
click to toggle source
# File lib/beckett/node/element.rb, line 15 def node_attributes unless defined?(@node_attributes) @node_attributes = node.attr @node_attributes = nil if @node_attributes.empty? end @node_attributes end
node_name()
click to toggle source
# File lib/beckett/node/element.rb, line 23 def node_name @node_name ||= node.type.upcase end
node_type()
click to toggle source
# File lib/beckett/node/element.rb, line 27 def node_type 1 end