Class: Biomart::Server

Inherits:
Object
  • Object
show all
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

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Biomart

#request

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

#urlObject (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.

Returns:

  • (Boolean)


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

#databasesHash

Returns a hash (keyed by the biomart ‘name’ for the database) of all of the Biomart::Database objects belonging to this server.

Returns:

  • (Hash)

    A hash of Biomart::Database objects keyed by the database name



34
35
36
37
38
39
# File 'lib/biomart/server.rb', line 34

def databases
  if @databases.empty?
    fetch_databases
  end
  return @databases
end

#datasetsObject

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_databasesArray

Returns an array of the database names (biomart ‘name’) for this dataset.

Returns:

  • (Array)

    An array of database names



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_datasetsObject

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