Class: Incite::Source
- Inherits:
-
Object
- Object
- Incite::Source
- Defined in:
- lib/incite/source.rb
Instance Attribute Summary collapse
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#city ⇒ Object
Returns the value of attribute city.
-
#edition ⇒ Object
Returns the value of attribute edition.
-
#editors ⇒ Object
Returns the value of attribute editors.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#title ⇒ Object
Returns the value of attribute title.
-
#translators ⇒ Object
Returns the value of attribute translators.
-
#volume ⇒ Object
Returns the value of attribute volume.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #citation(type) ⇒ Object
- #has_attributes?(attrs) ⇒ Boolean
-
#initialize(attrs = {}) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(attrs = {}) ⇒ Source
Returns a new instance of Source.
7 8 9 10 11 12 13 14 15 |
# File 'lib/incite/source.rb', line 7 def initialize(attrs={}) attrs.each do |attr, value| self.send("#{attr}=", value) end self.pages ||= [] self. ||= [] self.editors ||= [] self.translators ||= [] end |
Instance Attribute Details
#authors ⇒ Object
Returns the value of attribute authors.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def @authors end |
#city ⇒ Object
Returns the value of attribute city.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def city @city end |
#edition ⇒ Object
Returns the value of attribute edition.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def edition @edition end |
#editors ⇒ Object
Returns the value of attribute editors.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def editors @editors end |
#pages ⇒ Object
Returns the value of attribute pages.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def pages @pages end |
#publisher ⇒ Object
Returns the value of attribute publisher.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def publisher @publisher end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def title @title end |
#translators ⇒ Object
Returns the value of attribute translators.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def translators @translators end |
#volume ⇒ Object
Returns the value of attribute volume.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def volume @volume end |
#year ⇒ Object
Returns the value of attribute year.
4 5 6 |
# File 'lib/incite/source.rb', line 4 def year @year end |
Instance Method Details
#citation(type) ⇒ Object
17 18 19 |
# File 'lib/incite/source.rb', line 17 def citation(type) citation = Incite.const_get(type.to_s.capitalize).new(self).to_html end |
#has_attributes?(attrs) ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/incite/source.rb', line 21 def has_attributes?(attrs) !attrs.map do |attr| value = send(attr) (value.is_a?(Array) && value.any?) || (!value.is_a?(Array) && !value.nil?) end.include?(false) end |