Class: MarkdownExtension::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_extension/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, type) ⇒ Config

Returns a new instance of Config.



15
16
17
18
19
20
# File 'lib/markdown_extension/config.rb', line 15

def initialize(file, type)
    @file = file
    @type = type
    load_file(file)
    return self
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/markdown_extension/config.rb', line 5

def file
  @file
end

#raw_configObject

Returns the value of attribute raw_config.



5
6
7
# File 'lib/markdown_extension/config.rb', line 5

def raw_config
  @raw_config
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/markdown_extension/config.rb', line 5

def type
  @type
end

Instance Method Details

#get_base_info(name) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/markdown_extension/config.rb', line 22

def get_base_info(name)
    if @raw_config
        if @raw_config[@type.to_s]
            return @raw_config[@type.to_s][name]
        end
    end
    ""
end

#giscusObject



53
54
55
56
57
# File 'lib/markdown_extension/config.rb', line 53

def giscus
    if @raw_config
        return @raw_config["giscus"]
    end
end

#journalsObject



43
44
45
# File 'lib/markdown_extension/config.rb', line 43

def journals
    get_base_info("journals")
end

#load_file(file) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/markdown_extension/config.rb', line 7

def load_file(file)
    @raw_config = begin
        Tomlrb.load_file(file)
    rescue
        {}
    end
end

#pagesObject



39
40
41
# File 'lib/markdown_extension/config.rb', line 39

def pages
    get_base_info("pages")
end

#preprocessingObject



47
48
49
50
51
# File 'lib/markdown_extension/config.rb', line 47

def preprocessing
    if @raw_config
        return @raw_config["preprocessing"]
    end
end

#srcObject



35
36
37
# File 'lib/markdown_extension/config.rb', line 35

def src
    get_base_info("src")
end

#titleObject



31
32
33
# File 'lib/markdown_extension/config.rb', line 31

def title
    get_base_info("title")
end