Class: Vedeu::Interface

Inherits:
Object
  • Object
show all
Includes:
Presentation, Queue, Style
Defined in:
lib/vedeu/models/interface.rb

Instance Method Summary collapse

Methods included from Style

#style, #style_original

Methods included from Queue

#dequeue, #enqueued?, #reset

Constructor Details

#initialize(attributes = {}) ⇒ Interface

Returns a new instance of Interface.



31
32
33
34
35
# File 'lib/vedeu/models/interface.rb', line 31

def initialize(attributes = {})
  Vedeu.events.on(:refresh) { refresh }

  super
end

Instance Method Details

#clearObject



37
38
39
# File 'lib/vedeu/models/interface.rb', line 37

def clear
  @_clear ||= ClearInterface.call(self)
end

#enqueueObject



41
42
43
# File 'lib/vedeu/models/interface.rb', line 41

def enqueue
  super(self.to_s)
end

#geometryObject



45
46
47
# File 'lib/vedeu/models/interface.rb', line 45

def geometry
  @_geometry ||= Geometry.new(attributes)
end

#origin(index = 0) ⇒ Object



49
50
51
# File 'lib/vedeu/models/interface.rb', line 49

def origin(index = 0)
  geometry.origin(index)
end

#refreshObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vedeu/models/interface.rb', line 53

def refresh
  if enqueued?
    self.current = dequeue

  elsif no_content?
    self.current = clear

  else
    self.current

  end
  Terminal.output(self.current)

  self.current
end

#to_json(*args) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/vedeu/models/interface.rb', line 69

def to_json(*args)
  {
    colour: colour,
    style:  style_original,
    name:   name,
    lines:  lines,
    y:      y,
    x:      x,
    width:  width,
    height: height,
    cursor: cursor
  }.to_json
end

#to_sObject



83
84
85
# File 'lib/vedeu/models/interface.rb', line 83

def to_s
  RenderInterface.call(self)
end