Class: TTK::Status

Inherits:
Object show all
Includes:
Abstract
Defined in:
lib/ttk/status.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatus

Returns a new instance of Status.



39
40
41
# File 'lib/ttk/status.rb', line 39

def initialize
  @weight = self.class.default_weight_value
end

Instance Attribute Details

#weightObject

Returns the value of attribute weight.



24
25
26
# File 'lib/ttk/status.rb', line 24

def weight
  @weight
end

Class Method Details

.default_weight_valueObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ttk/status.rb', line 26

def self.default_weight_value
  val = nil
  if const_defined? :DEFAULT_WEIGHT
    if const_defined? :DEFAULT_WEIGHT_VALUE
      val = const_get(:DEFAULT_WEIGHT_VALUE)
    else
      val = Weights::Default.new(const_get(:DEFAULT_WEIGHT))
      const_set(:DEFAULT_WEIGHT_VALUE, val)
    end
  end
  val
end

.hook_nameObject



47
48
49
# File 'lib/ttk/status.rb', line 47

def self.hook_name
  (status_name.to_s.downcase + '_hook').to_sym
end

.status_nameObject



43
44
45
# File 'lib/ttk/status.rb', line 43

def self.status_name
  name.sub(/^.*?(\w+)Status$/, '\1').upcase.to_sym
end

Instance Method Details

#exceptionObject



71
72
73
# File 'lib/ttk/status.rb', line 71

def exception
  StatusException.new(self)
end

#hook_nameObject



51
52
53
# File 'lib/ttk/status.rb', line 51

def hook_name
  self.class.hook_name
end

#pass?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/ttk/status.rb', line 67

def pass?
  false
end

#to_sObject



55
56
57
58
59
60
61
# File 'lib/ttk/status.rb', line 55

def to_s
  res = self.class.status_name.to_s
  if @weight != self.class.default_weight_value
    res += "(#{@weight.get})"
  end
  res
end

#to_ttk_log(log) ⇒ Object



63
64
65
# File 'lib/ttk/status.rb', line 63

def to_ttk_log ( log )
  log.status = self.to_s
end