Class: VER::Status::Label

Inherits:
Tk::Tile::Label
  • Object
show all
Includes:
LabelToggle
Defined in:
lib/ver/status/label.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LabelToggle

#toggle

Constructor Details

#initialize(status, options = {}) ⇒ Label

Returns a new instance of Label.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ver/status/label.rb', line 8

def initialize(status, options = {})
  @status = status
  @weight = options.delete(:weight) || 0
  @row = options.delete(:row)
  @column = options.delete(:column)
  @sticky = options.delete(:sticky)
  @format = options.delete(:format) || '%s'
  options[:font] ||= options.delete(:font) || buffer.options.font

  super

  id = Digest::MD5.hexdigest(tk_pathname)
  name = self.class.name[/::([^:]+)$/, 1]
  @variable = Tk::Variable.new("#{name}_#{id}")
  configure(textvariable: @variable)
  @destroyed = false

  bind('<Destroy>', &method(:on_destroy))

  setup
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def column
  @column
end

#formatObject (readonly)

Returns the value of attribute format.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def format
  @format
end

#rowObject (readonly)

Returns the value of attribute row.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def row
  @row
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def status
  @status
end

#stickyObject (readonly)

Returns the value of attribute sticky.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def sticky
  @sticky
end

#variableObject (readonly)

Returns the value of attribute variable.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def variable
  @variable
end

#weightObject (readonly)

Returns the value of attribute weight.



6
7
8
# File 'lib/ver/status/label.rb', line 6

def weight
  @weight
end

Instance Method Details

#bufferObject



41
42
43
# File 'lib/ver/status/label.rb', line 41

def buffer
  status.buffer
end

#destroyed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ver/status/label.rb', line 30

def destroyed?
  @destroyed
end

#on_destroy(event) ⇒ Object



34
35
36
# File 'lib/ver/status/label.rb', line 34

def on_destroy(event)
  @destroyed = true
end

#register(*events) ⇒ Object



49
50
51
# File 'lib/ver/status/label.rb', line 49

def register(*events)
  status.register(self, *events)
end

#setupObject



38
39
# File 'lib/ver/status/label.rb', line 38

def setup
end

#style=(config) ⇒ Object



53
54
55
# File 'lib/ver/status/label.rb', line 53

def style=(config)
  configure(config) unless destroyed?
end

#to_sObject



57
58
59
# File 'lib/ver/status/label.rb', line 57

def to_s
  ''
end

#update(event) ⇒ Object



45
46
47
# File 'lib/ver/status/label.rb', line 45

def update(event)
  variable.set(to_s) unless destroyed?
end