Class: HardCiter::Bibliography
- Inherits:
-
Object
- Object
- HardCiter::Bibliography
- Defined in:
- lib/hardciter/bibliography.rb
Instance Attribute Summary collapse
-
#bib_out_line ⇒ Object
Returns the value of attribute bib_out_line.
-
#bib_out_match ⇒ Object
Returns the value of attribute bib_out_match.
-
#bibliography_intext ⇒ Object
Returns the value of attribute bibliography_intext.
-
#bit_out_location ⇒ Object
Returns the value of attribute bit_out_location.
-
#citation_locations ⇒ Object
Returns the value of attribute citation_locations.
-
#citations ⇒ Object
Returns the value of attribute citations.
-
#intext_regex ⇒ Object
Returns the value of attribute intext_regex.
Instance Method Summary collapse
- #add_citation(intext_match) ⇒ Object
- #get_or_create_citation(intext_match) ⇒ Object
- #has_bibliography_key?(line) ⇒ Boolean
-
#initialize ⇒ Bibliography
constructor
A new instance of Bibliography.
- #next_citation_index ⇒ Object
- #pair_match_to_citation(intext_match, line_num) ⇒ Object
- #set_bib_out(intext_match, line_num) ⇒ Object
Constructor Details
#initialize ⇒ Bibliography
Returns a new instance of Bibliography.
6 7 8 9 10 11 |
# File 'lib/hardciter/bibliography.rb', line 6 def initialize @bibliography_intext = HardCiter.configuration.bibliography_pattern @intext_regex = HardCiter.configuration.intext_pattern @citation_locations = {} @citations = {} end |
Instance Attribute Details
#bib_out_line ⇒ Object
Returns the value of attribute bib_out_line.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def bib_out_line @bib_out_line end |
#bib_out_match ⇒ Object
Returns the value of attribute bib_out_match.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def bib_out_match @bib_out_match end |
#bibliography_intext ⇒ Object
Returns the value of attribute bibliography_intext.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def bibliography_intext @bibliography_intext end |
#bit_out_location ⇒ Object
Returns the value of attribute bit_out_location.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def bit_out_location @bit_out_location end |
#citation_locations ⇒ Object
Returns the value of attribute citation_locations.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def citation_locations @citation_locations end |
#citations ⇒ Object
Returns the value of attribute citations.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def citations @citations end |
#intext_regex ⇒ Object
Returns the value of attribute intext_regex.
3 4 5 |
# File 'lib/hardciter/bibliography.rb', line 3 def intext_regex @intext_regex end |
Instance Method Details
#add_citation(intext_match) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/hardciter/bibliography.rb', line 39 def add_citation(intext_match) citation = HardCiter::Citation.new(intext_match.cite_key) citation.bib_number = next_citation_index @citations[citation.key] = citation citation end |
#get_or_create_citation(intext_match) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/hardciter/bibliography.rb', line 27 def get_or_create_citation(intext_match) if @citations.has_key?(intext_match.cite_key) @citations[intext_match.cite_key] else add_citation(intext_match) end end |
#has_bibliography_key?(line) ⇒ Boolean
35 36 37 |
# File 'lib/hardciter/bibliography.rb', line 35 def has_bibliography_key?(line) line =~ @bibliography_intext end |
#next_citation_index ⇒ Object
46 47 48 |
# File 'lib/hardciter/bibliography.rb', line 46 def next_citation_index @citations.length + 1 end |
#pair_match_to_citation(intext_match, line_num) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/hardciter/bibliography.rb', line 13 def pair_match_to_citation(intext_match,line_num) if intext_match.type == HardCiter::BIBLIOGRAPHY_OUT_MATCH set_bib_out(intext_match,line_num) nil else get_or_create_citation(intext_match) end end |
#set_bib_out(intext_match, line_num) ⇒ Object
22 23 24 25 |
# File 'lib/hardciter/bibliography.rb', line 22 def set_bib_out(intext_match,line_num) @bib_out_line = line_num @bib_out_match = intext_match end |