Class: SequenceServer::Database

Inherits:
Struct::Database
  • Object
show all
Defined in:
lib/database.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) name

Returns the value of attribute name



2
3
4
# File 'lib/database.rb', line 2

def name
  @name
end

- (Object) title

Returns the value of attribute title



2
3
4
# File 'lib/database.rb', line 2

def title
  @title
end

Instance Method Details

- (Object) <=>(other)

Its not very meaningful to compare Database objects, however, we still add the 'spaceship' operator to be able to sort the databases by 'title', or 'name' for better visual presentation.

We use 'title' for comparison, while relying on 'name' as fallback.

Trying to sort a list of dbs with 'title' set only for some of them will obviously produce unpredictable sorting order.



15
16
17
18
19
20
21
# File 'lib/database.rb', line 15

def <=>(other)
  if self.title and other.title
    self.title <=> other.title
  else
    self.name <=> other.name
  end
end

- (Object) to_s



3
4
5
# File 'lib/database.rb', line 3

def to_s
  "#{title} #{name}"
end