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))


9
10
11
12
# File 'lib/docker/messages_stack.rb', line 9

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

Instance Attribute Details

#messagesObject

Returns the value of attribute messages.



4
5
6
# File 'lib/docker/messages_stack.rb', line 4

def messages
  @messages
end

Instance Method Details

#append(messages) ⇒ Object

Append messages to stack

Parameters:



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

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