Class: CodeBlockParser

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Parser

#setNext

Constructor Details

#initialize(isForJekyll) ⇒ CodeBlockParser

Returns a new instance of CodeBlockParser.



7
8
9
# File 'lib/Parsers/CodeBlockParser.rb', line 7

def initialize(isForJekyll)
    @isForJekyll = isForJekyll
end

Instance Attribute Details

#isForJekyllObject

Returns the value of attribute isForJekyll.



5
6
7
# File 'lib/Parsers/CodeBlockParser.rb', line 5

def isForJekyll
  @isForJekyll
end

#nextParserObject

Returns the value of attribute nextParser.



5
6
7
# File 'lib/Parsers/CodeBlockParser.rb', line 5

def nextParser
  @nextParser
end

Class Method Details

.getTypeStringObject



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

def self.getTypeString()
    'CODE_BLOCK'
end

.isCodeBlock(paragraph) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/Parsers/CodeBlockParser.rb', line 15

def self.isCodeBlock(paragraph)
    if paragraph.nil? 
        false
    else
        paragraph.type == CodeBlockParser.getTypeString()
    end
end

Instance Method Details

#parse(paragraph) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Parsers/CodeBlockParser.rb', line 23

def parse(paragraph)
    if CodeBlockParser.isCodeBlock(paragraph)
        result = "```\n"
        
        result += paragraph.text.chomp

        result += "\n```"
    else
        if !nextParser.nil?
            nextParser.parse(paragraph)
        end
    end
end