Class: AsciidoctorBibliography::CitationItem

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor-bibliography/citation_item.rb

Constant Summary collapse

LOCATORS =
CiteProc::CitationItem.labels.map(&:to_s).push("locator").freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ CitationItem

Returns a new instance of CitationItem.

Yields:

  • (_self)

Yield Parameters:



9
10
11
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 9

def initialize
  yield self if block_given?
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 7

def key
  @key
end

#named_attributesObject

Returns the value of attribute named_attributes.



7
8
9
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 7

def named_attributes
  @named_attributes
end

#positional_attributesObject

Returns the value of attribute positional_attributes.



7
8
9
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 7

def positional_attributes
  @positional_attributes
end

#targetObject

Returns the value of attribute target.



7
8
9
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 7

def target
  @target
end

Instance Method Details

#locatorObject



29
30
31
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 29

def locator
  locators.first
end

#locatorsObject



25
26
27
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 25

def locators
  named_attributes.select { |key, _| LOCATORS.include? key }
end

#parse_attribute_list(string) ⇒ Object



33
34
35
36
37
38
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 33

def parse_attribute_list(string)
  parsed_attributes = ::Asciidoctor::AttributeList.new(string).parse
  self.named_attributes = parsed_attributes.reject { |key, _| key.is_a? Integer }
  self.positional_attributes = parsed_attributes.select { |key, _| key.is_a? Integer }.values
  self.key = positional_attributes.shift
end

#prefixObject



13
14
15
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 13

def prefix
  named_attributes["prefix"]
end

#suffixObject



17
18
19
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 17

def suffix
  named_attributes["suffix"]
end

#textObject



21
22
23
# File 'lib/asciidoctor-bibliography/citation_item.rb', line 21

def text
  named_attributes["text"]
end