From ffa818b7b49a44ff4643c61ac2da038cfa6f2929 Mon Sep 17 00:00:00 2001 From: iberianpig Date: Mon, 29 Jan 2024 23:55:35 +0900 Subject: [PATCH] refactor: buffer#empty? --- lib/fusuma/plugin/buffers/buffer.rb | 5 +++++ lib/fusuma/plugin/buffers/gesture_buffer.rb | 4 ---- lib/fusuma/plugin/buffers/timer_buffer.rb | 4 ---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/fusuma/plugin/buffers/buffer.rb b/lib/fusuma/plugin/buffers/buffer.rb index 600aad3..f9b2bfe 100644 --- a/lib/fusuma/plugin/buffers/buffer.rb +++ b/lib/fusuma/plugin/buffers/buffer.rb @@ -31,6 +31,11 @@ def buffer(event) def clear_expired(current_time: Time.now) end + # @return [TrueClass, FalseClass] + def empty? + @events.empty? + end + # clear buffer def clear @events.clear diff --git a/lib/fusuma/plugin/buffers/gesture_buffer.rb b/lib/fusuma/plugin/buffers/gesture_buffer.rb index 5ce17b9..72de536 100644 --- a/lib/fusuma/plugin/buffers/gesture_buffer.rb +++ b/lib/fusuma/plugin/buffers/gesture_buffer.rb @@ -127,10 +127,6 @@ def gesture @events.last.record.gesture end - def empty? - @events.empty? - end - def select_by_events(&block) return enum_for(:select_by_events) unless block diff --git a/lib/fusuma/plugin/buffers/timer_buffer.rb b/lib/fusuma/plugin/buffers/timer_buffer.rb index 441bced..e31863a 100644 --- a/lib/fusuma/plugin/buffers/timer_buffer.rb +++ b/lib/fusuma/plugin/buffers/timer_buffer.rb @@ -34,10 +34,6 @@ def clear_expired(current_time: Time.now) @events.delete(e) end end - - def empty? - @events.empty? - end end end end