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.



9
10
11
# File 'lib/Parsers/CodeBlockParser.rb', line 9

def initialize(isForJekyll)
    @isForJekyll = isForJekyll
end

Instance Attribute Details

#isForJekyllObject

Returns the value of attribute isForJekyll.



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

def isForJekyll
  @isForJekyll
end

#nextParserObject

Returns the value of attribute nextParser.



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

def nextParser
  @nextParser
end

Class Method Details

.getTypeStringObject



13
14
15
# File 'lib/Parsers/CodeBlockParser.rb', line 13

def self.getTypeString()
    'CODE_BLOCK'
end

.isCodeBlock(paragraph) ⇒ Object



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

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

Instance Method Details

#parse(paragraph) ⇒ Object



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

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