Class: Kuby::Pipe

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/kuby/dev_setup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, cli) ⇒ Pipe

Returns a new instance of Pipe.



104
105
106
107
108
109
# File 'lib/kuby/dev_setup.rb', line 104

def initialize(name, cli)
  @name = T.let(name, Symbol)
  @cli = T.let(cli, T.untyped)
  @out = T.let(StringIO.new, StringIO)
  @err = T.let(StringIO.new, StringIO)
end

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



95
96
97
# File 'lib/kuby/dev_setup.rb', line 95

def cli
  @cli
end

#errObject (readonly)

Returns the value of attribute err.



101
102
103
# File 'lib/kuby/dev_setup.rb', line 101

def err
  @err
end

#nameObject (readonly)

Returns the value of attribute name.



92
93
94
# File 'lib/kuby/dev_setup.rb', line 92

def name
  @name
end

#outObject (readonly)

Returns the value of attribute out.



98
99
100
# File 'lib/kuby/dev_setup.rb', line 98

def out
  @out
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/kuby/dev_setup.rb', line 119

def success?
  cli.last_status.nil? || cli.last_status.success?
end

#wrap(&block) ⇒ Object



112
113
114
115
116
# File 'lib/kuby/dev_setup.rb', line 112

def wrap(&block)
  cli.with_pipes(out, err) do
    block.call
  end
end