Class: VER::Status::Label

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Label.



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

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) || text.options.font

  super

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

  setup
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def column
  @column
end

#formatObject (readonly)

Returns the value of attribute format.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def format
  @format
end

#rowObject (readonly)

Returns the value of attribute row.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def row
  @row
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def status
  @status
end

#stickyObject (readonly)

Returns the value of attribute sticky.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def sticky
  @sticky
end

#variableObject (readonly)

Returns the value of attribute variable.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def variable
  @variable
end

#weightObject (readonly)

Returns the value of attribute weight.



4
5
6
# File 'lib/ver/status/label.rb', line 4

def weight
  @weight
end

Instance Method Details

#register(*events) ⇒ Object



32
33
34
# File 'lib/ver/status/label.rb', line 32

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

#setupObject



25
26
# File 'lib/ver/status/label.rb', line 25

def setup
end

#style=(config) ⇒ Object



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

def style=(config)
  configure(config)
end

#textObject



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

def text
  status.text
end

#to_sObject



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

def to_s
  ''
end

#toggleObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ver/status/label.rb', line 48

def toggle
  info = grid_info

  if info.empty?
    grid_configure(@last_grid_info)
    true
  else
    @last_grid_info = info
    grid_forget
    false
  end
end

#update(event) ⇒ Object



28
29
30
# File 'lib/ver/status/label.rb', line 28

def update(event)
  variable.set(to_s)
end