Class: SubSpawn::Internal::FdSource::Basic

Inherits:
SubSpawn::Internal::FdSource show all
Defined in:
lib/subspawn/fd_types.rb

Overview

TODO: :tty in list shouldn’t get here!

Direct Known Subclasses

Temp

Instance Attribute Summary

Attributes inherited from SubSpawn::Internal::FdSource

#all_dests, #dests

Instance Method Summary collapse

Methods inherited from SubSpawn::Internal::FdSource

#depends?, #destroys?, #raw_apply

Constructor Details

#initialize(dests, int) ⇒ Basic

Returns a new instance of Basic.



41
42
43
44
# File 'lib/subspawn/fd_types.rb', line 41

def initialize(dests, int)
  super(dests)
  @value = int
end

Instance Method Details

#apply(base) ⇒ Object



72
73
74
# File 'lib/subspawn/fd_types.rb', line 72

def apply base
  raw_apply base, @value
end

#before?(o) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
60
61
62
# File 'lib/subspawn/fd_types.rb', line 57

def before? o
  # we are before o if:
  # o destroys any of our sources
  # or we depend on o
  depends? o or o.destroys? @value
end

#depend?(o) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/subspawn/fd_types.rb', line 51

def depend? o
  o.dests.include? @value
end

#headsObject



63
64
65
# File 'lib/subspawn/fd_types.rb', line 63

def heads
  [@value]
end

#maxObject



45
46
47
# File 'lib/subspawn/fd_types.rb', line 45

def max
  [@dests.max, @value].max
end

#sourceObject



48
49
50
# File 'lib/subspawn/fd_types.rb', line 48

def source
  @value
end

#tailsObject



66
67
68
# File 'lib/subspawn/fd_types.rb', line 66

def tails
  @dests
end

#temp_source(new) ⇒ Object



54
55
56
# File 'lib/subspawn/fd_types.rb', line 54

def temp_source(new)
  self.class.new(@dests, new)
end

#to_dbgObject



69
70
71
# File 'lib/subspawn/fd_types.rb', line 69

def to_dbg
  [@dests, @value]
end