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.



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/asciidoctor/document.rb', line 113

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)



111
112
113
# File 'lib/asciidoctor/document.rb', line 111

def combined
  @combined
end

#mainObject (readonly) Also known as: title



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

def main
  @main
end

#subtitleObject (readonly)



110
111
112
# File 'lib/asciidoctor/document.rb', line 110

def subtitle
  @subtitle
end

Instance Method Details

#sanitized?Boolean

Returns:

  • (Boolean)


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

def sanitized?
  @sanitized
end

#subtitle?Boolean

Returns:

  • (Boolean)


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

def subtitle?
  @subtitle ? true : false
end

#to_sObject



135
136
137
# File 'lib/asciidoctor/document.rb', line 135

def to_s
  @combined
end