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

#setNext

Constructor Details

#initialize(isForJekyll) ⇒ MIXTAPEEMBEDParser

Returns a new instance of MIXTAPEEMBEDParser.



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

def initialize(isForJekyll)
    @isForJekyll = isForJekyll
end

Instance Attribute Details

#isForJekyllObject

Returns the value of attribute isForJekyll.



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

def isForJekyll
  @isForJekyll
end

#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



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Parsers/MIXTAPEEMBEDParser.rb', line 14

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