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



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/asciidoctor/document.rb', line 46

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



44
45
46
# File 'lib/asciidoctor/document.rb', line 44

def combined
  @combined
end

#mainObject (readonly) Also known as: title

Returns the value of attribute main



41
42
43
# File 'lib/asciidoctor/document.rb', line 41

def main
  @main
end

#subtitleObject (readonly)

Returns the value of attribute subtitle



43
44
45
# File 'lib/asciidoctor/document.rb', line 43

def subtitle
  @subtitle
end

Instance Method Details

#sanitized?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/asciidoctor/document.rb', line 60

def sanitized?
  @sanitized
end

#subtitle?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/asciidoctor/document.rb', line 64

def subtitle?
  @subtitle ? true : false
end

#to_sObject



68
69
70
# File 'lib/asciidoctor/document.rb', line 68

def to_s
  @combined
end