Class: TTK::Streams::Stream

Inherits:
Object show all
Defined in:
lib/ttk/strategies/Streams/Stream.rb

Direct Known Subclasses

Diff, Pipe

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, ref = nil) ⇒ Stream

Constructor



24
25
26
# File 'lib/ttk/strategies/Streams/Stream.rb', line 24

def initialize ( name, ref=nil )
  @name, @my, @ref = name.to_s, TempPath.new(name), ref
end

Instance Attribute Details

#myObject

Attributes



17
18
19
# File 'lib/ttk/strategies/Streams/Stream.rb', line 17

def my
  @my
end

#nameObject

Attributes



17
18
19
# File 'lib/ttk/strategies/Streams/Stream.rb', line 17

def name
  @name
end

#refObject

Attributes



17
18
19
# File 'lib/ttk/strategies/Streams/Stream.rb', line 17

def ref
  @ref
end

Instance Method Details

#cleanObject



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ttk/strategies/Streams/Stream.rb', line 50

def clean
  if @my.is_a? Pathname
    @my.unlink if @my.exist? and @my.temp?
  end
  if @ref.is_a? Pathname
    @ref.unlink if @ref.exist? and @ref.temp?
  elsif @ref.is_a? File
    ref = Pathname.new(@ref.path)
    ref.unlink if ref.exist? and ref.temp?
  end
end

#compare_streamsObject

Methods



33
34
35
36
37
38
# File 'lib/ttk/strategies/Streams/Stream.rb', line 33

def compare_streams
  return @cmp if defined? @cmp
  @cmp = @ref.compare_stream(@my)
  @status = @cmp ? :PASS : :FAILED
  @cmp
end

#statusObject



40
41
42
43
# File 'lib/ttk/strategies/Streams/Stream.rb', line 40

def status
  compare_streams
  @status
end

#to_ttk_log(log) ⇒ Object



45
46
47
48
# File 'lib/ttk/strategies/Streams/Stream.rb', line 45

def to_ttk_log ( log )
  log["my_#@name"] = @my.to_s_for_ttk_log
  log["ref_#@name"] = @ref.to_s_for_ttk_log unless @ref.nil?
end