Class: Nuklear::UI::Progress
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#modifiable ⇒ Object
writeonly
Sets the attribute modifiable.
Instance Method Summary collapse
-
#initialize(enabled: true, min: 1, max: 100, current: 1, modifiable: true) ⇒ Progress
constructor
A new instance of Progress.
- #modifiable? ⇒ Boolean
- #result(x, context) ⇒ Object
- #to_command ⇒ Object
Methods inherited from Base
Methods included from Enableable
#disable, #disabled=, #disabled?, #enable, #enabled=, #enabled?
Methods included from Events
#event_listeners_for, #on, #trigger
Constructor Details
#initialize(enabled: true, min: 1, max: 100, current: 1, modifiable: true) ⇒ Progress
Returns a new instance of Progress.
7 8 9 10 11 12 13 14 |
# File 'lib/nuklear/ui/progress.rb', line 7 def initialize(enabled: true, min: 1, max: 100, current: 1, modifiable: true) super enabled: enabled @min = min @max = max @current = current @modifiable = modifiable on(:changed) { yield @current } if block_given? end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
4 5 6 |
# File 'lib/nuklear/ui/progress.rb', line 4 def current @current end |
#max ⇒ Object
Returns the value of attribute max.
4 5 6 |
# File 'lib/nuklear/ui/progress.rb', line 4 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
4 5 6 |
# File 'lib/nuklear/ui/progress.rb', line 4 def min @min end |
#modifiable=(value) ⇒ Object (writeonly)
Sets the attribute modifiable
5 6 7 |
# File 'lib/nuklear/ui/progress.rb', line 5 def modifiable=(value) @modifiable = value end |
Instance Method Details
#modifiable? ⇒ Boolean
20 21 22 |
# File 'lib/nuklear/ui/progress.rb', line 20 def modifiable? @modifiable end |
#result(x, context) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/nuklear/ui/progress.rb', line 24 def result(x, context) x = min if x < min return unless x != @current @current = x trigger :changed @last_event = nil end |
#to_command ⇒ Object
16 17 18 |
# File 'lib/nuklear/ui/progress.rb', line 16 def to_command [:ui_progress, current, max, modifiable?] end |