Class: MIXTAPEEMBEDParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Parser

#initialize, #setNext

Constructor Details

This class inherits a constructor from Parser

Instance Attribute Details

#nextParserObject

Returns the value of attribute nextParser.



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

def nextParser
  @nextParser
end

Instance Method Details

#parse(paragraph) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/Parsers/MIXTAPEEMBEDParser.rb', line 9

def parse(paragraph)
    if paragraph.type == 'MIXTAPE_EMBED'
        if !paragraph..nil? && !paragraph..href.nil?
            ogImageURL = Helper.fetchOGImage(paragraph..href)
            if !ogImageURL.nil?
                "\r\n\r\n[![#{paragraph.text}](#{ogImageURL} \"#{paragraph.text}\")](#{paragraph.mixtapeMetadata.href})\r\n\r\n"
            else
                "\n[#{paragraph.text}](#{paragraph.mixtapeMetadata.href})"
            end
        else
            "\n#{paragraph.text}"
        end
    else
        if !nextParser.nil?
            nextParser.parse(paragraph)
        end
    end
end