Class: Asciidoctor::Document::Title
- Inherits:
-
Object
- Object
- Asciidoctor::Document::Title
- Defined in:
- lib/asciidoctor/document.rb
Overview
Public Parsed and stores a partitioned title (i.e., title & subtitle).
Instance Attribute Summary collapse
- #combined ⇒ Object readonly
- #main ⇒ Object (also: #title) readonly
- #subtitle ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(val, opts = {}) ⇒ Title
constructor
A new instance of Title.
- #sanitized? ⇒ Boolean
- #subtitle? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(val, opts = {}) ⇒ Title
Returns a new instance of Title.
115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/asciidoctor/document.rb', line 115 def initialize val, opts = {} # TODO separate sanitization by type (:cdata for HTML/XML, :plain_text for non-SGML, false for none) if (@sanitized = opts[:sanitize]) && (val.include? '<') val = val.gsub(XmlSanitizeRx, '').squeeze(' ').strip end if (sep = opts[:separator] || ':').empty? || !(val.include? (sep = %(#{sep} ))) @main = val @subtitle = nil else @main, _, @subtitle = val.rpartition sep end @combined = val end |
Instance Attribute Details
#combined ⇒ Object (readonly)
113 114 115 |
# File 'lib/asciidoctor/document.rb', line 113 def combined @combined end |
#main ⇒ Object (readonly) Also known as: title
110 111 112 |
# File 'lib/asciidoctor/document.rb', line 110 def main @main end |
#subtitle ⇒ Object (readonly)
112 113 114 |
# File 'lib/asciidoctor/document.rb', line 112 def subtitle @subtitle end |
Instance Method Details
#sanitized? ⇒ Boolean
129 130 131 |
# File 'lib/asciidoctor/document.rb', line 129 def sanitized? @sanitized end |
#subtitle? ⇒ Boolean
133 134 135 |
# File 'lib/asciidoctor/document.rb', line 133 def subtitle? @subtitle ? true : false end |
#to_s ⇒ Object
137 138 139 |
# File 'lib/asciidoctor/document.rb', line 137 def to_s @combined end |