Class: MarkdownExtension::Config
- Inherits:
-
Object
- Object
- MarkdownExtension::Config
- Defined in:
- lib/markdown_extension/config.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#raw_config ⇒ Object
Returns the value of attribute raw_config.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #get_base_info(name) ⇒ Object
- #giscus ⇒ Object
-
#initialize(file, type) ⇒ Config
constructor
A new instance of Config.
- #journals ⇒ Object
- #load_file(file) ⇒ Object
- #pages ⇒ Object
- #preprocessing ⇒ Object
- #src ⇒ Object
- #title ⇒ Object
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
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/markdown_extension/config.rb', line 5 def file @file end |
#raw_config ⇒ Object
Returns the value of attribute raw_config.
5 6 7 |
# File 'lib/markdown_extension/config.rb', line 5 def raw_config @raw_config end |
#type ⇒ Object
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 |
#giscus ⇒ Object
53 54 55 56 57 |
# File 'lib/markdown_extension/config.rb', line 53 def giscus if @raw_config return @raw_config["giscus"] end end |
#journals ⇒ Object
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 |
#pages ⇒ Object
39 40 41 |
# File 'lib/markdown_extension/config.rb', line 39 def pages get_base_info("pages") end |
#preprocessing ⇒ Object
47 48 49 50 51 |
# File 'lib/markdown_extension/config.rb', line 47 def preprocessing if @raw_config return @raw_config["preprocessing"] end end |
#src ⇒ Object
35 36 37 |
# File 'lib/markdown_extension/config.rb', line 35 def src get_base_info("src") end |
#title ⇒ Object
31 32 33 |
# File 'lib/markdown_extension/config.rb', line 31 def title get_base_info("title") end |