Class: Asciidoctor::Document::Title

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/document.rb

Overview

Public Parsed and stores a partitioned title (i.e., title & subtitle).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val, opts = {}) ⇒ Title

Returns a new instance of Title



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/asciidoctor/document.rb', line 109

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

#combinedObject (readonly)

Returns the value of attribute combined



107
108
109
# File 'lib/asciidoctor/document.rb', line 107

def combined
  @combined
end

#mainObject (readonly) Also known as: title

Returns the value of attribute main



104
105
106
# File 'lib/asciidoctor/document.rb', line 104

def main
  @main
end

#subtitleObject (readonly)

Returns the value of attribute subtitle



106
107
108
# File 'lib/asciidoctor/document.rb', line 106

def subtitle
  @subtitle
end

Instance Method Details

#sanitized?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/asciidoctor/document.rb', line 123

def sanitized?
  @sanitized
end

#subtitle?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/asciidoctor/document.rb', line 127

def subtitle?
  @subtitle ? true : false
end

#to_sObject



131
132
133
# File 'lib/asciidoctor/document.rb', line 131

def to_s
  @combined
end