Class: Biomart::Server
- Inherits:
-
Object
- Object
- Biomart::Server
- Includes:
- Biomart
- Defined in:
- lib/biomart/server.rb
Overview
Class representation for a biomart server. Will contain many Biomart::Database and Biomart::Dataset objects.
Constant Summary
Constants included from Biomart
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
Simple heartbeat function to test that a Biomart server is online.
-
#databases ⇒ Hash
Returns a hash (keyed by the biomart ‘name’ for the database) of all of the Biomart::Database objects belonging to this server.
-
#datasets ⇒ Object
Returns a hash (keyed by the biomart ‘name’ for the dataset) of all of the Biomart::Dataset objects belonging to this server.
-
#initialize(url) ⇒ Server
constructor
A new instance of Server.
-
#list_databases ⇒ Array
Returns an array of the database names (biomart ‘name’) for this dataset.
-
#list_datasets ⇒ Object
Returns an array of the dataset names (biomart ‘name’) for this dataset.
Methods included from Biomart
Constructor Details
#initialize(url) ⇒ Server
Returns a new instance of Server.
9 10 11 12 13 14 15 16 17 |
# File 'lib/biomart/server.rb', line 9 def initialize( url ) @url = url or raise ArgumentError, "must pass :url" unless @url =~ /martservice/ @url = @url + "/martservice" end @databases = {} @datasets = {} end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/biomart/server.rb', line 7 def url @url end |
Instance Method Details
#alive? ⇒ Boolean
Simple heartbeat function to test that a Biomart server is online. Returns true/false.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/biomart/server.rb', line 61 def alive? begin @databases = {} # reset the databases store self.list_databases rescue Biomart::BiomartError => e return false else return true end end |
#databases ⇒ Hash
Returns a hash (keyed by the biomart ‘name’ for the database) of all of the Biomart::Database objects belonging to this server.
34 35 36 37 38 39 |
# File 'lib/biomart/server.rb', line 34 def databases if @databases.empty? fetch_databases end return @databases end |
#datasets ⇒ Object
Returns a hash (keyed by the biomart ‘name’ for the dataset) of all of the Biomart::Dataset objects belonging to this server.
52 53 54 55 56 57 |
# File 'lib/biomart/server.rb', line 52 def datasets if @datasets.empty? fetch_datasets end return @datasets end |
#list_databases ⇒ Array
Returns an array of the database names (biomart ‘name’) for this dataset.
23 24 25 26 27 28 |
# File 'lib/biomart/server.rb', line 23 def list_databases if @databases.empty? fetch_databases end return @databases.keys end |
#list_datasets ⇒ Object
Returns an array of the dataset names (biomart ‘name’) for this dataset.
43 44 45 46 47 48 |
# File 'lib/biomart/server.rb', line 43 def list_datasets if @datasets.empty? fetch_datasets end return @datasets.keys end |