Class: ShelfTag

Inherits:
DoubleTag show all
Defined in:
lib/objective_elements/shelf_tag.rb

Overview

This is a nonexistent HTML tag, which holds content like a double tag but has no opening or closing tag. This allows us to group siblings without adding an extra parent to the markup.

Instance Attribute Summary

Attributes inherited from DoubleTag

#content, #oneline

Attributes inherited from SingleTag

#attributes, #element

Instance Method Summary collapse

Methods inherited from DoubleTag

#add_content, #reset_content, #to_s

Methods inherited from SingleTag

#method_missing, #reset_attributes, #respond_to_missing?, #to_s

Constructor Details

#initialize(content: nil, oneline: false) ⇒ ShelfTag

A shelf has no element of its own, so it never renders an opening tag.



8
9
10
# File 'lib/objective_elements/shelf_tag.rb', line 8

def initialize(content: nil, oneline: false)
  super(nil, content: content, oneline: oneline)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SingleTag

Instance Method Details

#add_parent(parent) ⇒ Object



16
17
18
# File 'lib/objective_elements/shelf_tag.rb', line 16

def add_parent(parent)
  parent.add_content content
end

#to_aObject



12
13
14
# File 'lib/objective_elements/shelf_tag.rb', line 12

def to_a
  content.map { |c| build_content_line c }.flatten
end