Sha256: 74268787617b15e888f6d55a3bf9f0633c625c6e5b200deb99c43d18a2dd5311
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module Vedeu # Maintains which interface is current in focus. class Focus def initialize register_events self end # @param name [String] # @return [] def add(name) if registered?(name) storage else storage << name end end # @param name [String] # @return [] def by_name(name) fail InterfaceNotFound unless storage.include?(name) storage.rotate!(storage.index(name)) current end # @return [] def current fail NoInterfacesDefined if storage.empty? storage.first end # @return [] def next_item storage.rotate! current end # @return [] def prev_item storage.rotate!(-1) current end # @return [] def register_events Vedeu.event(:_focus_next_) { next_item } Vedeu.event(:_focus_prev_) { prev_item } Vedeu.event(:_focus_by_name_) { |name| by_name(name) } end private def registered?(name) return false if storage.empty? storage.include?(name) end def storage @storage ||= [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.17 | lib/vedeu/support/focus.rb |