Class: Docker::MessagesStack

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/messages_stack.rb

Overview

This class represents a messages stack

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size = -1)) ⇒ MessagesStack

Initialize stack with optional size

Parameters:

  • size (Integer) (defaults to: -1))


11
12
13
14
# File 'lib/docker/messages_stack.rb', line 11

def initialize(size = -1)
  @messages = []
  @size = size
end

Instance Attribute Details

#messagesObject

Returns the value of attribute messages.



6
7
8
# File 'lib/docker/messages_stack.rb', line 6

def messages
  @messages
end

Instance Method Details

#append(messages) ⇒ Object

Append messages to stack

Parameters:



19
20
21
22
23
24
25
26
# File 'lib/docker/messages_stack.rb', line 19

def append(messages)
  return if @size == 0

  messages.all_messages.each do |msg|
    @messages << msg
    @messages.shift if @size > -1 && @messages.size > @size
  end
end