Class: Fate::Output::IOMux

Inherits:
Object
  • Object
show all
Defined in:
lib/fate/output.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ IOMux

Returns a new instance of IOMux.



49
50
51
52
53
54
55
56
57
# File 'lib/fate/output.rb', line 49

def initialize(options)
  @last_identifier = nil
  if file = options[:file]
    @io = File.new(file, "a")
  elsif io = options[:io]
    @io = io
  end
  @handlers = {}
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



47
48
49
# File 'lib/fate/output.rb', line 47

def io
  @io
end

#last_identifierObject

Returns the value of attribute last_identifier.



48
49
50
# File 'lib/fate/output.rb', line 48

def last_identifier
  @last_identifier
end

Instance Method Details

#[](name) ⇒ Object



59
60
61
# File 'lib/fate/output.rb', line 59

def [](name)
  @handlers[name] ||= IOFilter.new(self, name)
end

#format(name, string) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/fate/output.rb', line 63

def format(name, string)
  if name == @last_identifier
    string
  else
    @last_identifier = name
    "==> #{name} <==\n#{string}"
  end
end