Class: Nuklear::UI::Progress

Inherits:
Base
  • Object
show all
Defined in:
lib/nuklear/ui/progress.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

descendants, #dsl, inherited

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

#currentObject

Returns the value of attribute current.



4
5
6
# File 'lib/nuklear/ui/progress.rb', line 4

def current
  @current
end

#maxObject

Returns the value of attribute max.



4
5
6
# File 'lib/nuklear/ui/progress.rb', line 4

def max
  @max
end

#minObject

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

Parameters:

  • value

    the value to set the attribute modifiable to.



5
6
7
# File 'lib/nuklear/ui/progress.rb', line 5

def modifiable=(value)
  @modifiable = value
end

Instance Method Details

#modifiable?Boolean

Returns:

  • (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_commandObject



16
17
18
# File 'lib/nuklear/ui/progress.rb', line 16

def to_command
  [:ui_progress, current, max, modifiable?]
end