Class: Kubec::Status::Base
- Inherits:
-
Object
- Object
- Kubec::Status::Base
- Includes:
- Enumerable
- Defined in:
- lib/kubec/status/base.rb
Overview
:nodoc:
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #each(&_block) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
30 31 32 33 34 35 36 37 |
# File 'lib/kubec/status/base.rb', line 30 def initialize @type = self.class.name.split('::').last.downcase @result = `kubectl -n #{fetch(:stage, :staging)} get #{@type} -o json` @success = $CHILD_STATUS.success? @items = [] prepare end |
Class Method Details
.fields(fields = nil) ⇒ Object
16 17 18 19 |
# File 'lib/kubec/status/base.rb', line 16 def fields(fields = nil) return @fields if fields.nil? @fields = fields end |
.print ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/kubec/status/base.rb', line 21 def print if fields.nil? ptus Hirb::Helpers::AutoTable.render(new) else puts Hirb::Helpers::AutoTable.render(new, fields: fields) end end |
Instance Method Details
#each(&_block) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/kubec/status/base.rb', line 39 def each(&_block) return unless @success @items.each do |item| yield self.class.const_get('Item').new(item) end end |