Class: MDOM::CodeBlock
Instance Attribute Summary collapse
-
#literal ⇒ Object
readonly
Returns the value of attribute literal.
Attributes inherited from Node
#attributes, #children, #parent, #type
Instance Method Summary collapse
- #fenced? ⇒ Boolean
-
#initialize(literal, lang: nil, fenced: true, attributes: {}) ⇒ CodeBlock
constructor
lang: language string (may be nil), fenced: true/false, literal: source text.
- #lang ⇒ Object
- #to_s ⇒ Object
Methods inherited from Node
#[], #ancestors, #append, #children?, #depth, #each_child, #empty?, #find, #find_all, #insert_after, #insert_before, #inspect, #plain_text, #pretty_print, #remove, #replace, #root, #text?, #to_markdown, #walk
Constructor Details
#initialize(literal, lang: nil, fenced: true, attributes: {}) ⇒ CodeBlock
lang: language string (may be nil), fenced: true/false, literal: source text
81 82 83 84 85 86 87 |
# File 'lib/mdom/nodes.rb', line 81 def initialize(literal, lang: nil, fenced: true, attributes: {}) attrs = { fenced: fenced }.merge(attributes) attrs[:lang] = lang unless lang.nil? super(Types::CODE_BLOCK, attributes: attrs) # Code block text is kept as a raw string, not child nodes. @literal = literal end |
Instance Attribute Details
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
89 90 91 |
# File 'lib/mdom/nodes.rb', line 89 def literal @literal end |
Instance Method Details
#fenced? ⇒ Boolean
95 96 97 |
# File 'lib/mdom/nodes.rb', line 95 def fenced? attributes[:fenced] end |
#lang ⇒ Object
91 92 93 |
# File 'lib/mdom/nodes.rb', line 91 def lang attributes[:lang] end |
#to_s ⇒ Object
99 100 101 |
# File 'lib/mdom/nodes.rb', line 99 def to_s "#<MDOM::CodeBlock fenced=#{fenced?} lang=#{lang.inspect}>" end |