Class: Obp::Access::Renderer::Elements::Base
- Inherits:
-
Object
- Object
- Obp::Access::Renderer::Elements::Base
- Defined in:
- lib/obp/access/elements/base.rb
Direct Known Subclasses
Array, Bibliography, Copyright, DispFormula, Figure, FigureGroup, Footnotes, Index, Introduction, List, NonNormativeExample, NonNormativeNote, Paragraph, ProtectedContentNote, Section, TableWrap, Terminology, Terminology::Tig, Title
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Elements are rendered using the NISO STS spec: https://www.niso-sts.org/TagLibrary/niso-sts-TL-1-2-html/index.html.
-
#metas ⇒ Object
readonly
Elements are rendered using the NISO STS spec: https://www.niso-sts.org/TagLibrary/niso-sts-TL-1-2-html/index.html.
-
#node ⇒ Object
readonly
Elements are rendered using the NISO STS spec: https://www.niso-sts.org/TagLibrary/niso-sts-TL-1-2-html/index.html.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(document:, metas:, node:) ⇒ Base
constructor
A new instance of Base.
-
#match_node? ⇒ Boolean
Subset match: OBP varies class order and adds marker classes (e.g. "commentable"), so a node matches when it carries at least the registered classes, regardless of order or extras.
- #render(target:) ⇒ Object
Constructor Details
#initialize(document:, metas:, node:) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 |
# File 'lib/obp/access/elements/base.rb', line 10 def initialize(document:, metas:, node:) @document = document @metas = @node = node end |
Instance Attribute Details
#document ⇒ Object (readonly)
Elements are rendered using the NISO STS spec: https://www.niso-sts.org/TagLibrary/niso-sts-TL-1-2-html/index.html
8 9 10 |
# File 'lib/obp/access/elements/base.rb', line 8 def document @document end |
#metas ⇒ Object (readonly)
Elements are rendered using the NISO STS spec: https://www.niso-sts.org/TagLibrary/niso-sts-TL-1-2-html/index.html
8 9 10 |
# File 'lib/obp/access/elements/base.rb', line 8 def @metas end |
#node ⇒ Object (readonly)
Elements are rendered using the NISO STS spec: https://www.niso-sts.org/TagLibrary/niso-sts-TL-1-2-html/index.html
8 9 10 |
# File 'lib/obp/access/elements/base.rb', line 8 def node @node end |
Class Method Details
.classes ⇒ Object
16 17 18 |
# File 'lib/obp/access/elements/base.rb', line 16 def self.classes nil end |
Instance Method Details
#match_node? ⇒ Boolean
Subset match: OBP varies class order and adds marker classes (e.g. "commentable"), so a node matches when it carries at least the registered classes, regardless of order or extras.
23 24 25 |
# File 'lib/obp/access/elements/base.rb', line 23 def match_node? (self.class.classes - node.classes).empty? end |
#render(target:) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/obp/access/elements/base.rb', line 27 def render(target:) # Top-level nodes without their own insertion target (e.g. a # floating sts-p between sections) default to the body. effective_target = insertion_target || target || "body" effective_target = "#{effective_target}#{path_suffix}" if path_suffix document.at(effective_target).public_send(insert_method, to_xml) end |