Class: Charming::Presentation::Markdown::RenderContext
- Inherits:
-
Data
- Object
- Data
- Charming::Presentation::Markdown::RenderContext
- Defined in:
- lib/charming/presentation/markdown/render_context.rb
Overview
RenderContext carries the state needed to render nested Markdown blocks: the current list nesting depth (used for indentation) and the wrap width.
Instance Attribute Summary collapse
-
#list_depth ⇒ Object
readonly
Returns the value of attribute list_depth.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
-
.from(width:, list_depth: 0) ⇒ Object
Builds a new RenderContext with the given width and optional starting list_depth.
Instance Method Summary collapse
-
#nested(depth_increment: 0, width: self.width) ⇒ Object
Returns a derived context with the list depth incremented by depth_increment and the wrap width overridden to width (defaults to the current width).
Instance Attribute Details
#list_depth ⇒ Object (readonly)
Returns the value of attribute list_depth
8 9 10 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 8 def list_depth @list_depth end |
#width ⇒ Object (readonly)
Returns the value of attribute width
8 9 10 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 8 def width @width end |
Class Method Details
.from(width:, list_depth: 0) ⇒ Object
Builds a new RenderContext with the given width and optional starting list_depth.
10 11 12 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 10 def self.from(width:, list_depth: 0) new(list_depth: list_depth, width: width) end |
Instance Method Details
#nested(depth_increment: 0, width: self.width) ⇒ Object
Returns a derived context with the list depth incremented by depth_increment and the wrap width overridden to width (defaults to the current width).
16 17 18 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 16 def nested(depth_increment: 0, width: self.width) self.class.new(list_depth: list_depth + depth_increment, width: width) end |