From 422a15a09efd2d44fe53c5ce2c46bc8b5aee08e6 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 25 Dec 2016 14:51:25 +0100 Subject: last --- last.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'last.go') diff --git a/last.go b/last.go index 34a3022..50524dd 100644 --- a/last.go +++ b/last.go @@ -12,21 +12,21 @@ type Msg struct { Text string } -type LastBuf struct { +type Last struct { *ring.Ring } -func NewLastBuf(n int) *LastBuf { - return &LastBuf{ring.New(n)} +func NewLast(n int) *Last { + return &Last{ring.New(n)} } -func (v *LastBuf) Push(t time.Time, nick, text string) { +func (v *Last) Push(t time.Time, nick, text string) { v.Value = Msg{Time: t, Nick: nick, Text: text} v.Ring = v.Next() } // walk through buffer and find last message -func (v *LastBuf) Last(nick string) string { +func (v *Last) Last(nick string) string { var msg string v.Do(func(v interface{}) { if l, ok := v.(Msg); ok { @@ -38,7 +38,7 @@ func (v *LastBuf) Last(nick string) string { return msg } -func (v *LastBuf) Dump(c chan string) { +func (v *Last) Dump(c chan string) { v.Do(func(v interface{}) { if l, ok := v.(Msg); ok { c <- fmt.Sprintf("%v <%v> %v", -- cgit v1.2.3