Class: AsciidoctorVaped::Parser::Context
- Inherits:
-
Object
- Object
- AsciidoctorVaped::Parser::Context
- Defined in:
- lib/asciidoctor_vaped/parser/context.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#pending_attributes ⇒ Object
readonly
Returns the value of attribute pending_attributes.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
Instance Method Summary collapse
- #add_pending_attributes(attributes) ⇒ Object
- #append(node) ⇒ Object
-
#initialize(document, reader, parent: nil) ⇒ Context
constructor
A new instance of Context.
- #nested(parent, reader = @reader) ⇒ Object
- #open_section(section) ⇒ Object
- #pending_title=(title) ⇒ Object
Constructor Details
#initialize(document, reader, parent: nil) ⇒ Context
Returns a new instance of Context.
8 9 10 11 12 13 14 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 8 def initialize(document, reader, parent: nil) @document = document @reader = reader @parent = parent @sections = [] @pending_attributes = {} end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
6 7 8 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 6 def document @document end |
#pending_attributes ⇒ Object (readonly)
Returns the value of attribute pending_attributes.
6 7 8 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 6 def pending_attributes @pending_attributes end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
6 7 8 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 6 def reader @reader end |
Instance Method Details
#add_pending_attributes(attributes) ⇒ Object
32 33 34 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 32 def add_pending_attributes(attributes) @pending_attributes.merge!(attributes) end |
#append(node) ⇒ Object
20 21 22 23 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 20 def append(node) node.attributes.merge!(consume_attributes) parent << node end |
#nested(parent, reader = @reader) ⇒ Object
16 17 18 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 16 def nested(parent, reader = @reader) self.class.new(document, reader, parent:) end |
#open_section(section) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 25 def open_section(section) level = section.attributes.fetch(:level) @sections.pop while @sections.any? && @sections.last.attributes.fetch(:level) >= level parent << section @sections << section end |
#pending_title=(title) ⇒ Object
36 37 38 |
# File 'lib/asciidoctor_vaped/parser/context.rb', line 36 def pending_title=(title) @pending_attributes[:title] = title end |