Class: Bioroebe::Biomart::Server

Inherits:
Object
  • Object
show all
Includes:
Bioroebe::Biomart
Defined in:
lib/bioroebe/biomart/server.rb

Overview

Bioroebe::Biomart::Attribute

Instance Method Summary collapse

Methods included from Bioroebe::Biomart

#request

Constructor Details

#initialize(url) ⇒ Server

#

initialize

#


22
23
24
25
26
27
28
# File 'lib/bioroebe/biomart/server.rb', line 22

def initialize(url)
  @url = url or raise ArgumentError, 'must pass :url'
  unless @url =~ /martservice/
    @url = @url+'/martservice'
  end
  reset
end

Instance Method Details

#alive?Boolean

#

alive?

Simple heartbeat function to test that a Biomart server is online. Returns true/false.

#

Returns:

  • (Boolean)


114
115
116
117
118
119
120
121
122
123
124
# File 'lib/bioroebe/biomart/server.rb', line 114

def alive?
  begin
    @databases = {} # reset the databases store
    self.list_databases
  rescue Biomart::BiomartError => error
    pp error
    return false
  else
    return true
  end
end

#databases?Hash Also known as: databases

#

databases?

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

database name.

#

Returns:

  • (Hash)

    A hash of Biomart::Database objects keyed by the



75
76
77
78
79
80
# File 'lib/bioroebe/biomart/server.rb', line 75

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

#datasets?Boolean Also known as: datasets

#

datasets?

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

#

Returns:

  • (Boolean)


101
102
103
104
105
106
# File 'lib/bioroebe/biomart/server.rb', line 101

def datasets?
  if @datasets.empty?
    fetch_datasets
  end
  return @datasets
end

#list_databasesArray

#

list_databases

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

#

Returns:

  • (Array)

    An array of database names



52
53
54
55
56
57
# File 'lib/bioroebe/biomart/server.rb', line 52

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

#list_datasetsObject

#

list_datasets

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

#


88
89
90
91
92
93
# File 'lib/bioroebe/biomart/server.rb', line 88

def list_datasets
  if @datasets.empty?
    fetch_datasets
  end
  return @datasets.keys
end

#resetObject

#

reset

#


33
34
35
36
37
38
39
40
41
42
# File 'lib/bioroebe/biomart/server.rb', line 33

def reset
  # ======================================================================= #
  # === @databases
  # ======================================================================= #
  @databases = {}
  # ======================================================================= #
  # === @datasets
  # ======================================================================= #
  @datasets  = {}
end

#url?Boolean Also known as: url

#

url?

#

Returns:

  • (Boolean)


62
63
64
# File 'lib/bioroebe/biomart/server.rb', line 62

def url?
  @url
end