Class: Liza::Panel

Inherits:
Unit
  • Object
show all
Defined in:
lib/liza/base/panel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Unit

const_missing, part, #system, system, test_class

Constructor Details

#initialize(key) ⇒ Panel

Returns a new instance of Panel.



60
61
62
63
64
65
# File 'lib/liza/base/panel.rb', line 60

def initialize key
  @key = key
  @blocks = []
  @unstarted = true
  @short = {}
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



58
59
60
# File 'lib/liza/base/panel.rb', line 58

def key
  @key
end

Class Method Details

.boxObject



14
15
16
# File 'lib/liza/base/panel.rb', line 14

def self.box
  system.box
end

.colorObject

color



52
53
54
# File 'lib/liza/base/panel.rb', line 52

def self.color
  system.color
end

.controllerObject



22
23
24
# File 'lib/liza/base/panel.rb', line 22

def self.controller
  @controller ||= system.const token
end

.divisionObject



30
31
32
# File 'lib/liza/base/panel.rb', line 30

def self.division
  controller.division
end

.subsystemObject



42
43
44
# File 'lib/liza/base/panel.rb', line 42

def self.subsystem
  controller
end

.tokenObject



38
39
40
# File 'lib/liza/base/panel.rb', line 38

def self.token
  @token ||= last_namespace.gsub(/Panel$/, '').snakecase.to_sym
end

Instance Method Details

#boxObject



18
19
20
# File 'lib/liza/base/panel.rb', line 18

def box
  system.box
end

#controllerObject



26
27
28
# File 'lib/liza/base/panel.rb', line 26

def controller
  self.class.controller
end

#divisionObject



34
35
36
# File 'lib/liza/base/panel.rb', line 34

def division
  controller.division
end

#push(block) ⇒ Object



79
80
81
82
# File 'lib/liza/base/panel.rb', line 79

def push block
  @unstarted = true
  @blocks.push block
end

#short(a, b = nil) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/liza/base/panel.rb', line 69

def short a, b = nil
  if b
    @short[a.to_s] = b.to_s
  else
    @short[a.to_s] || a.to_s
  end
end

#startedObject



84
85
86
87
88
89
90
91
92
# File 'lib/liza/base/panel.rb', line 84

def started
  return self unless defined? @unstarted
  remove_instance_variable :@unstarted

  @blocks.each { |bl| instance_eval(&bl) }
  @blocks.clear

  self
end

#subsystemObject



46
47
48
# File 'lib/liza/base/panel.rb', line 46

def subsystem
  controller
end