Class: Fitting::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/host.rb

Defined Under Namespace

Classes: NotFound, Skip

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, skip) ⇒ Host

Returns a new instance of Host.



12
13
14
15
16
# File 'lib/fitting/host.rb', line 12

def initialize(host, skip)
  @host = host
  @skip = skip
  @cover = false
end

Class Method Details

.find!(log) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
# File 'lib/fitting/host.rb', line 18

def self.find!(log)
  yaml = YAML.safe_load(File.read('.fitting.yml'))
  yaml['hosts']&.map do |host|
    if log.host == host.first.first
      return new(host.first.first, host.first.last)
    end
  end
  raise NotFound.new(log.host, log)
end

Instance Method Details

#cover!Object

Raises:



28
29
30
31
# File 'lib/fitting/host.rb', line 28

def cover!
  @cover = true
  raise Skip if @skip == 'skip'
end

#to_sObject



33
34
35
# File 'lib/fitting/host.rb', line 33

def to_s
  @host
end