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

Returns a new instance of ShelfTag.



5
6
7
8
# File 'lib/objective_elements/shelf_tag.rb', line 5

def initialize(content: nil, oneline: false)
  self.oneline = oneline
  self.content = content
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



14
15
16
# File 'lib/objective_elements/shelf_tag.rb', line 14

def add_parent(parent)
  parent.add_content content
end

#to_aObject



10
11
12
# File 'lib/objective_elements/shelf_tag.rb', line 10

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