Sha256: 8ee2f3cba2187883f2633288784eae040a99ad9e757b4c04a6604f3f3e717aa8
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
require 'forwardable' require 'virtus' require 'vedeu' require 'vedeu/models/attributes/line_collection' require 'vedeu/models/colour' require 'vedeu/models/style' require 'vedeu/output/clear_interface' require 'vedeu/output/render_interface' require 'vedeu/models/geometry' require 'vedeu/support/queue' require 'vedeu/support/terminal' # Todo: mutation (events, current) module Vedeu class Interface extend Forwardable include Vedeu::Queue include Virtus.model attribute :name, String attribute :group, String attribute :lines, LineCollection attribute :colour, Colour, default: Colour.new attribute :style, Style, default: '' attribute :geometry, Geometry, default: Geometry.new attribute :current, String, default: '' attribute :cursor, Boolean, default: true attribute :delay, Float, default: 0 def_delegators :@geometry, :north, :east, :south, :west, :top, :right, :bottom, :left def initialize(attributes = {}) super Vedeu.events.on(:_refresh_, self.delay) { refresh } Vedeu.events.on("_refresh_group_#{group}_".to_sym, self.delay) { refresh } unless group.nil? || group.empty? Vedeu.events.on("_refresh_#{name}_".to_sym, self.delay) { refresh } self end def clear @_clear ||= ClearInterface.call(self) end def enqueue super(self.to_s) end def refresh if enqueued? self.current = dequeue elsif no_content? self.current = clear else self.current end Terminal.output(self.current) self.current end def to_s RenderInterface.call(self) end private def no_content? self.current.nil? || self.current.empty? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.7 | lib/vedeu/models/interface.rb |