Module: Horatio::Detector::IOHandler

Included in:
Docker, Dynamic, Maven, NodePackage
Defined in:
lib/horatio/detector/io_handler.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



10
11
12
# File 'lib/horatio/detector/io_handler.rb', line 10

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/horatio/detector/io_handler.rb', line 10

def output
  @output
end

Class Method Details

.included(base) ⇒ Object



39
40
41
# File 'lib/horatio/detector/io_handler.rb', line 39

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#default_inputObject



12
13
14
# File 'lib/horatio/detector/io_handler.rb', line 12

def default_input
  'horatio.json'
end

#default_outputObject



16
17
18
# File 'lib/horatio/detector/io_handler.rb', line 16

def default_output
  'horatio.json'
end

#detectObject



27
28
29
# File 'lib/horatio/detector/io_handler.rb', line 27

def detect
  File.exists?(@input) ? true : nil
end

#initialize(input: nil, output: nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/horatio/detector/io_handler.rb', line 20

def initialize(input: nil, output: nil)
  @input = input || default_input
  @output = output || default_output
  @info = {}
  @read = false
end

#memo_readObject



31
32
33
34
35
36
37
# File 'lib/horatio/detector/io_handler.rb', line 31

def memo_read
  return @info if @read
  return unless block_given?
  @info = yield
  @read = true
  @info
end