Class: Qiita::Markdown::Filters::CustomBlock::Note
- Inherits:
-
Object
- Object
- Qiita::Markdown::Filters::CustomBlock::Note
- Defined in:
- lib/qiita/markdown/filters/custom_block.rb
Constant Summary collapse
- ALLOWED_TYPES =
%w[info warn alert].freeze
- DEFAULT_TYPE =
"info".freeze
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(node, type) ⇒ Note
constructor
A new instance of Note.
Constructor Details
#initialize(node, type) ⇒ Note
Returns a new instance of Note.
38 39 40 41 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 38 def initialize(node, type) @node = node @type = ALLOWED_TYPES.include?(type) ? type : DEFAULT_TYPE end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
31 32 33 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 31 def node @node end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
31 32 33 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 31 def type @type end |
Instance Method Details
#convert ⇒ Object
43 44 45 46 47 |
# File 'lib/qiita/markdown/filters/custom_block.rb', line 43 def convert node.inner_html = node["class"] = "note #{type}" node.children.first.add_previous_sibling(icon) if icon end |