class PirateGame::LogBook
Public Class Methods
new(size = 10)
click to toggle source
# File lib/pirate_game/log_book.rb, line 7 def initialize size = 10 @mutex = Mutex.new @log_book = [] @size = size end
Public Instance Methods
add(entry, author = 'unknown')
click to toggle source
# File lib/pirate_game/log_book.rb, line 13 def add entry, author = 'unknown' @mutex.synchronize do @log_book << [entry, author] @log_book.shift if @log_book.size > @size end end
each() { |entry, author| ... }
click to toggle source
# File lib/pirate_game/log_book.rb, line 21 def each return enum_for __method__ unless block_given? @log_book.each do |(entry, author)| yield [entry, author] end end
empty?()
click to toggle source
# File lib/pirate_game/log_book.rb, line 29 def empty? @log_book.empty? end
length()
click to toggle source
# File lib/pirate_game/log_book.rb, line 33 def length @log_book.length end
Also aliased as: size