Class: MarkupParser

Inherits:
Object
  • Object
show all
Defined in:
lib/Parsers/MarkupParser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html, paragraph) ⇒ MarkupParser

Returns a new instance of MarkupParser.



10
11
12
13
# File 'lib/Parsers/MarkupParser.rb', line 10

def initialize(html, paragraph)
    @body = html.search("body").first
    @paragraph = paragraph
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



8
9
10
# File 'lib/Parsers/MarkupParser.rb', line 8

def body
  @body
end

#paragraphObject

Returns the value of attribute paragraph.



8
9
10
# File 'lib/Parsers/MarkupParser.rb', line 8

def paragraph
  @paragraph
end

Instance Method Details

#parseObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/Parsers/MarkupParser.rb', line 15

def parse()
    result = paragraph.text
    if paragraph.hasMarkup
        p = body.at_css("##{paragraph.name}")
        if !p.nil?
            result = ReverseMarkdown.convert p.inner_html
        end
    end

    result
end