Class: Bio::UniChem::Sources
- Inherits:
-
Object
- Object
- Bio::UniChem::Sources
- Defined in:
- lib/bio-unichem/model.rb
Overview
Constant Summary collapse
- Data =
data.strip.split("\/\/").map do |record| t = record.strip.split("\n").map {|line| line.strip } Bio::UniChem::Source.new({"src_id" => t[0], "short_name" => t[1], "full_name" => t[2], "description" => t[3], "process_of_data_acquisition" => t[4]}) end
Class Method Summary collapse
-
.[](arg) ⇒ Object
Bio::UniChem::Sources #=> aSource arg : src_id, short_name.
-
.find_by_short_name(short_name) ⇒ Object
Bio::UniChem::Sources.find_by_short_name(short_name) #=> aSource.
-
.find_by_src_id(src_id) ⇒ Object
Bio::UniChem::Sources.find_by_src_id(src_id) #=> aSource.
Class Method Details
.[](arg) ⇒ Object
Bio::UniChem::Sources #=> aSource arg : src_id, short_name
152 153 154 155 156 157 158 159 |
# File 'lib/bio-unichem/model.rb', line 152 def self.[](arg) case arg when /^\d$/ self.find_by_src_id(arg) else self.find_by_short_name(arg) end end |
.find_by_short_name(short_name) ⇒ Object
Bio::UniChem::Sources.find_by_short_name(short_name) #=> aSource
146 147 148 |
# File 'lib/bio-unichem/model.rb', line 146 def self.find_by_short_name(short_name) Data.find {|x| x.short_name == short_name } end |
.find_by_src_id(src_id) ⇒ Object
Bio::UniChem::Sources.find_by_src_id(src_id) #=> aSource
141 142 143 |
# File 'lib/bio-unichem/model.rb', line 141 def self.find_by_src_id(src_id) Data.find {|x| x.src_id == src_id.to_s } end |