[BioRuby-cvs] bioruby/lib/bio reference.rb,1.18,1.19
Mitsuteru C. Nakao
nakao at pub.open-bio.org
Sun Jan 29 07:39:34 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio
In directory pub.open-bio.org:/tmp/cvs-serv8071/lib/bio
Modified Files:
reference.rb
Log Message:
* Added RDoc.
Index: reference.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/reference.rb,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** reference.rb 18 Dec 2005 16:58:58 -0000 1.18
--- reference.rb 29 Jan 2006 07:39:31 -0000 1.19
***************
*** 1,6 ****
#
! # bio/reference.rb - journal reference class
#
! # Copyright (C) 2001 KATAYAMA Toshiaki <k at bioruby.org>
#
# This library is free software; you can redistribute it and/or
--- 1,22 ----
#
! # = bio/reference.rb - Journal reference classes
#
! # Copyright:: Copyright (C) 2001
! # KATAYAMA Toshiaki <k at bioruby.org>
! # Lisence:: LGPL
! #
! # $Id$
! #
! # == Description
! #
! # Journal reference classes.
! #
! # == Examples
! #
! # == References
! #
! #
! #
! #--
#
# This library is free software; you can redistribute it and/or
***************
*** 18,28 ****
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! # $Id$
#
module Bio
class Reference
def initialize(hash)
hash.default = ''
--- 34,100 ----
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
! #++
#
module Bio
+ # A class for journal reference information.
+ #
+ # === Examples
+ #
+ # hash = {'authors' => [ "Hoge, J.P.", "Fuga, F.B." ], 'title' => "Title of the study.",
+ # 'journal' => "Theor. J. Hoge", 'volume' => 12, 'issue' => 3, 'pages' => "123-145",
+ # 'year' => 2001, 'pubmed' => 12345678, 'medline' => 98765432, 'abstract' => "...",
+ # ''url' => "http://...", 'mesh' => [], 'affiliations' => []}
+ # ref = Bio::Reference.new(hash)
+ #
+ # # Formats in the BiBTeX style.
+ # ref.format("bibtex")
+ #
+ # # Short-cut for Bio::Reference#format("bibtex")
+ # ref.bibtex
+ #
class Reference
+ # Author names in an Array, [ "Hoge, J.P.", "Fuga, F.B." ].
+ attr_reader :authors
+
+ # "Title of the study."
+ attr_reader :title
+
+ # "Theor. J. Hoge"
+ attr_reader :journal
+
+ # 12
+ attr_reader :volume
+
+ # 3
+ attr_reader :issue
+
+ # "123-145"
+ attr_reader :pages
+
+ # 2001
+ attr_reader :year
+
+ # 12345678
+ attr_reader :pubmed
+
+ # 98765432
+ attr_reader :medline
+
+ # Abstract test in String.
+ attr_reader :abstract
+
+ # A URL String.
+ attr_reader :url
+
+ # MeSH terms in an Array.
+ attr_reader :mesh
+
+ # Affiliations in an Array.
+ attr_reader :affiliations
+
+ #
def initialize(hash)
hash.default = ''
***************
*** 44,50 ****
@affiliations = [] if @affiliations.empty?
end
- attr_reader :authors, :title, :journal, :volume, :issue, :pages, :year,
- :pubmed, :medline, :abstract, :url, :mesh, :affiliations
def format(style = nil, option = nil)
case style
--- 116,136 ----
@affiliations = [] if @affiliations.empty?
end
+ # Formats the reference in a given style.
+ #
+ # Styles:
+ # 0. nil - general
+ # 1. endnote - Endnote
+ # 2. bibitem - Bibitem (option acceptable)
+ # 3. bibtex - BiBTeX (option acceptable)
+ # 4. rd - rd (option acceptable)
+ # 5. nature - Nature (option acceptable)
+ # 6. science - Science
+ # 7. genome_biol - Genome Biology
+ # 8. genome_res - Genome Research
+ # 9. nar - Nucleic Acids Research
+ # 10. current - Current Biology
+ # 11. trends - Trends in *
+ # 12. cell - Cell Press
def format(style = nil, option = nil)
case style
***************
*** 78,81 ****
--- 164,168 ----
end
+ # Formats in the Endonote style.
def endnote
lines = []
***************
*** 105,108 ****
--- 192,196 ----
end
+ # Formats in the bibitem.
def bibitem(item = nil)
item = "PMID:#{@pubmed}" unless item
***************
*** 116,119 ****
--- 204,208 ----
end
+ # Formats in the BiBTeX style.
def bibtex(section = nil)
section = "article" unless section
***************
*** 133,136 ****
--- 222,226 ----
end
+ # Formats in a general style.
def general
authors = @authors.join(', ')
***************
*** 138,141 ****
--- 228,232 ----
end
+ # Formats in the RD style.
def rd(str = nil)
@abstract ||= str
***************
*** 148,151 ****
--- 239,244 ----
end
+ # Formats in the Nature Publish Group style.
+ # * http://www.nature.com
def nature(short = false)
if short
***************
*** 164,167 ****
--- 257,262 ----
end
+ # Formats in the Science style.
+ # * http://www.siencemag.com/
def science
if @authors.size > 4
***************
*** 174,177 ****
--- 269,274 ----
end
+ # Formats in the Genome Biology style.
+ # * http://genomebiology.com/
def genome_biol
authors = @authors.collect {|name| strip_dots(name)}.join(', ')
***************
*** 179,184 ****
--- 276,285 ----
"#{authors}: #{@title} #{journal} #{@year}, #{@volume}:#{@pages}."
end
+ # Formats in the Current Biology style.
+ # * http://www.current-biology.com/
alias current genome_biol
+ # Formats in the Genome Research style.
+ # * http://genome.org/
def genome_res
authors = authors_join(' and ')
***************
*** 186,189 ****
--- 287,292 ----
end
+ # Formats in the Nucleic Acids Reseach style.
+ # * http://nar.oxfordjournals.org/
def nar
authors = authors_join(' and ')
***************
*** 191,199 ****
end
def cell
authors = authors_join(' and ')
"#{authors} (#{@year}). #{@title} #{@journal} #{@volume}, #{pages}."
end
!
def trends
if @authors.size > 2
--- 294,306 ----
end
+ # Formats in the CELL Press style.
+ # http://www.cell.com/
def cell
authors = authors_join(' and ')
"#{authors} (#{@year}). #{@title} #{@journal} #{@volume}, #{pages}."
end
!
! # Formats in the TRENDS Journals.
! # * http://www.trends.com/
def trends
if @authors.size > 2
***************
*** 236,255 ****
end
!
class References
def initialize(ary = [])
@references = ary
end
- attr_accessor :references
! def append(a)
! @references.push(a) if a.is_a? Reference
return self
end
def each
! @references.each do |x|
! yield x
end
end
--- 343,377 ----
end
! # Set of Bio::Reference.
! #
! # === Examples
! #
! # refs = Bio::References.new
! # refs.append(Bio::Reference.new(hash))
! # refs.each do |reference|
! # ...
! # end
! #
class References
+ # Array of Bio::Reference.
+ attr_accessor :references
+
+ #
def initialize(ary = [])
@references = ary
end
!
! # Append a Bio::Reference object.
! def append(reference)
! @references.push(reference) if a.is_a? Reference
return self
end
+ # Iterates each Bio::Reference object.
def each
! @references.each do |reference|
! yield reference
end
end
***************
*** 258,308 ****
end
-
-
-
- =begin
-
- = Bio::Reference
-
- --- Bio::Reference.new(hash)
-
- --- Bio::Reference#authors -> Array
- --- Bio::Reference#title -> String
- --- Bio::Reference#journal -> String
- --- Bio::Reference#volume -> Fixnum
- --- Bio::Reference#issue -> Fixnum
- --- Bio::Reference#pages -> String
- --- Bio::Reference#year -> Fixnum
- --- Bio::Reference#pubmed -> Fixnum
- --- Bio::Reference#medline -> Fixnum
- --- Bio::Reference#abstract -> String
- --- Bio::Reference#url -> String
- --- Bio::Reference#mesh -> Array
- --- Bio::Reference#affiliations -> Array
-
- --- Bio::Reference#format(style = nil, option = nil) -> String
-
- --- Bio::Reference#endnote
- --- Bio::Reference#bibitem(item = nil) -> String
- --- Bio::Reference#bibtex(section = nil) -> String
- --- Bio::Reference#rd(str = nil) -> String
- --- Bio::Reference#nature(short = false) -> String
- --- Bio::Reference#science -> String
- --- Bio::Reference#genome_biol -> String
- --- Bio::Reference#genome_res -> String
- --- Bio::Reference#nar -> String
- --- Bio::Reference#cell -> String
- --- Bio::Reference#trends -> String
- --- Bio::Reference#general -> String
-
- = Bio::References
-
- --- Bio::References.new(ary = [])
-
- --- Bio::References#references -> Array
- --- Bio::References#append(a) -> Bio::References
- --- Bio::References#each -> Array
-
- =end
-
--- 380,382 ----
More information about the bioruby-cvs
mailing list