Class: Kreuzberg::Result::DjotContent::FormattedBlock
- Inherits:
-
Object
- Object
- Kreuzberg::Result::DjotContent::FormattedBlock
- Defined in:
- lib/kreuzberg/djot_content.rb
Overview
Represents a formatted block in Djot content
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#block_type ⇒ Object
readonly
Returns the value of attribute block_type.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
-
#initialize(hash_or_type = nil, children: nil, attributes: nil, content: nil, level: nil, block_type: nil) ⇒ FormattedBlock
constructor
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
-
#to_h ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
Constructor Details
#initialize(hash_or_type = nil, children: nil, attributes: nil, content: nil, level: nil, block_type: nil) ⇒ FormattedBlock
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kreuzberg/djot_content.rb', line 24 def initialize(hash_or_type = nil, children: nil, attributes: nil, content: nil, level: nil, block_type: nil) if hash_or_type.is_a?(Hash) # Initialize from hash @block_type = hash_or_type[:block_type] || hash_or_type['block_type'] || '' @children = hash_or_type[:children] || hash_or_type['children'] @attributes = hash_or_type[:attributes] || hash_or_type['attributes'] || {} @content = hash_or_type[:content] || hash_or_type['content'] @level = hash_or_type[:level] || hash_or_type['level'] else # Initialize from keyword arguments (for backward compatibility) @block_type = block_type || hash_or_type || '' @children = children || [] @attributes = attributes || {} @content = content @level = level end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
21 22 23 |
# File 'lib/kreuzberg/djot_content.rb', line 21 def attributes @attributes end |
#block_type ⇒ Object (readonly)
Returns the value of attribute block_type.
21 22 23 |
# File 'lib/kreuzberg/djot_content.rb', line 21 def block_type @block_type end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
21 22 23 |
# File 'lib/kreuzberg/djot_content.rb', line 21 def children @children end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
21 22 23 |
# File 'lib/kreuzberg/djot_content.rb', line 21 def content @content end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
21 22 23 |
# File 'lib/kreuzberg/djot_content.rb', line 21 def level @level end |
Instance Method Details
#to_h ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
43 44 45 46 47 48 49 50 51 |
# File 'lib/kreuzberg/djot_content.rb', line 43 def to_h { block_type: @block_type, children: @children, attributes: @attributes, content: @content, level: @level }.compact end |