Class: Shortcodes::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/shortcodes/parser.rb

Defined Under Namespace

Classes: Shortcode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Parser

Returns a new instance of Parser.



14
15
16
# File 'lib/shortcodes/parser.rb', line 14

def initialize(content)
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



12
13
14
# File 'lib/shortcodes/parser.rb', line 12

def content
  @content
end

Instance Method Details

#to_htmlObject



20
21
22
23
24
25
26
# File 'lib/shortcodes/parser.rb', line 20

def to_html
  content.gsub(/\[[^\]]+\]/) do |code|
    shortcode = parse_shortcode(code)

    get_handler(shortcode).call shortcode
  end
end