Class: BEL::Model::Citation

Inherits:
Struct
  • Object
show all
Defined in:
lib/bel/evidence_model/citation.rb

Overview

A Citation provides a reference to the resource containing the Evidence information. The fields are defined as:

  • date

    • The date represents when the article was published.

  • authors

    • The authors refer to the authors of the article.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorsString

the authors of the article

Returns:

  • (String)

    the current value of authors



20
21
22
# File 'lib/bel/evidence_model/citation.rb', line 20

def authors
  @authors
end

#commentString

a comment on the citation

Returns:

  • (String)

    the current value of comment



20
21
22
# File 'lib/bel/evidence_model/citation.rb', line 20

def comment
  @comment
end

#dateString

the date when the article was published

Returns:

  • (String)

    the current value of date



20
21
22
# File 'lib/bel/evidence_model/citation.rb', line 20

def date
  @date
end

#idString

the identifier of the article. For example, for a “PubMed” type the identifier is the PMID (i.e. 12102192)

Returns:

  • (String)

    the current value of id



20
21
22
# File 'lib/bel/evidence_model/citation.rb', line 20

def id
  @id
end

#nameString

the name of the article

Returns:

  • (String)

    the current value of name



20
21
22
# File 'lib/bel/evidence_model/citation.rb', line 20

def name
  @name
end

#typeString

the type of the article commonly defined by “PubMed”, “Journal”, “Book”, or “Online Resource”

Returns:

  • (String)

    the current value of type



20
21
22
# File 'lib/bel/evidence_model/citation.rb', line 20

def type
  @type
end

Class Method Details

.create(fields = {}) ⇒ Object

Creates a BEL::Model::Citation struct from a Hash.

Examples:

Create a minimal BEL::Model::Citation.

Citation.create(
  {
    :type => 'PubMed',
    :name => 'Biocompatibility study of biological tissues fixed
              by a natural compound (reuterin) produced by
              Lactobacillus reuteri.',
    :id   => '12102192'
  }
)

Create a full BEL::Model::Citation.

Citation.create(
  {
    :type    => 'PubMed',
    :name    => 'Biocompatibility study of biological tissues fixed
                 by a natural compound (reuterin) produced by
                 Lactobacillus reuteri.',
    :id      => '12102192',
    :date    => '2002-08-23',
    :authors => 'Sung HW|Chen CN|Chang Y|Liang HF',
    :comment => 'This article is primary research.'
  }
)

Parameters:

  • fields (Hash) (defaults to: {})

    the citation fields to populate based on hash keys



55
56
57
58
59
60
61
# File 'lib/bel/evidence_model/citation.rb', line 55

def self.create(fields = {})
  citation = Citation.new
  (Citation.members & fields.keys).each { |member|
    citation.send(:"#{member}=", fields[member])
  }
  citation
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/bel/evidence_model/citation.rb', line 63

def valid?
  type != nil && id != nil && name != nil
end