Class: Shift::InterfaceList

Inherits:
Object
  • Object
show all
Defined in:
lib/shift/interface_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(ifaces) ⇒ InterfaceList

Create a new InterfaceList, given an array of class names of shift interfaces. Immutable once created.



7
8
9
# File 'lib/shift/interface_list.rb', line 7

def initialize(ifaces)
  @interfaces = ifaces
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


15
16
17
# File 'lib/shift/interface_list.rb', line 15

def eql?(other)
  @interfaces.eql? other.to_hash
end

#hashObject



20
21
22
# File 'lib/shift/interface_list.rb', line 20

def hash
  @interfaces.hash
end

#inspectObject



24
25
26
# File 'lib/shift/interface_list.rb', line 24

def inspect
  'InterfaceList' + @interfaces.inspect
end

#pickClass

Pick the preferred available interface.

Returns:

  • (Class)

    The preferred available class

Raises:



35
36
37
38
39
# File 'lib/shift/interface_list.rb', line 35

def pick
  each_class {|kls| return kls if kls.available? }
  raise DependencyError, "nothing available: " +
    help_string
end

#to_hashObject



11
12
13
# File 'lib/shift/interface_list.rb', line 11

def to_hash
  @interfaces.dup
end