Class: MarkdownExtension::Citations
- Inherits:
-
Object
- Object
- MarkdownExtension::Citations
- Defined in:
- lib/markdown_extension/citations.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#inner_citations ⇒ Object
Returns the value of attribute inner_citations.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #add_inner_citation(file) ⇒ Object
- #get_inner_citation(id) ⇒ Object
- #init_citation ⇒ Object
-
#initialize(config, type) ⇒ Citations
constructor
A new instance of Citations.
Constructor Details
#initialize(config, type) ⇒ Citations
Returns a new instance of Citations.
4 5 6 7 8 9 10 11 |
# File 'lib/markdown_extension/citations.rb', line 4 def initialize(config, type) @config = config @type = type @inner_citations = {} if config.citation init_citation() end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/markdown_extension/citations.rb', line 3 def config @config end |
#inner_citations ⇒ Object
Returns the value of attribute inner_citations.
3 4 5 |
# File 'lib/markdown_extension/citations.rb', line 3 def inner_citations @inner_citations end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/markdown_extension/citations.rb', line 3 def type @type end |
Instance Method Details
#add_inner_citation(file) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/markdown_extension/citations.rb', line 16 def add_inner_citation(file) text = File.read(file) lines = text.split("\n")[4..-1] if lines i = 0 while(i < lines.size) do content = lines[i][2..-1] page_no = lines[i+2].split("hl-page:: ")[1] id = lines[i+3].split("id:: ")[1] @inner_citations[id] = "P#{page_no} #{content}" i = i + 4 end end end |
#get_inner_citation(id) ⇒ Object
31 32 33 |
# File 'lib/markdown_extension/citations.rb', line 31 def get_inner_citation(id) return @inner_citations[id] end |
#init_citation ⇒ Object
13 14 |
# File 'lib/markdown_extension/citations.rb', line 13 def init_citation() end |