Sha256: 048afbe4684ba5e37c80f221a75ea4528b4b145cf703ec8fbe364c5a816dce9e
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Vedeu class Interface attr_accessor :id, :attributes, :active, :name class << self def create(attributes = {}) new(attributes).create end end def initialize(attributes = {}) @attributes = attributes || {} @active = false @name = attributes[:name] end def create InterfaceRepository.create(self) InterfaceRepository.activate(self.name) self end def initial_state Compositor.arrange([Array.new(geometry.height) { '' }], name) end def geometry @geometry ||= Geometry.new(attributes) end def colour @colour ||= Colour.new([foreground, background]) end private def foreground attributes[:fg] || attributes[:foreground] end def background attributes[:bg] || attributes[:background] end end module ClassMethods def interface(name, options = {}) interface_name = name.is_a?(Symbol) ? name.to_s : name Interface.create({ name: interface_name }.merge!(options)) end end def self.included(receiver) receiver.extend(ClassMethods) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.0.16 | lib/vedeu/repository/interface.rb |
vedeu-0.0.15 | lib/vedeu/repository/interface.rb |