Class: Nuklear::UI::Property
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#inc_per_pixel ⇒ Object
Returns the value of attribute inc_per_pixel.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#step ⇒ Object
Returns the value of attribute step.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(enabled: true, text: '', min: 1, max: 100, current: 1, step: 1, inc_per_pixel: 1) ⇒ Property
constructor
A new instance of Property.
- #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, text: '', min: 1, max: 100, current: 1, step: 1, inc_per_pixel: 1) ⇒ Property
Returns a new instance of Property.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nuklear/ui/property.rb', line 6 def initialize(enabled: true, text: '', min: 1, max: 100, current: 1, step: 1, inc_per_pixel: 1) super enabled: enabled @text = text @min = min @max = max @current = current @step = step @inc_per_pixel = inc_per_pixel 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/property.rb', line 4 def current @current end |
#inc_per_pixel ⇒ Object
Returns the value of attribute inc_per_pixel.
4 5 6 |
# File 'lib/nuklear/ui/property.rb', line 4 def inc_per_pixel @inc_per_pixel end |
#max ⇒ Object
Returns the value of attribute max.
4 5 6 |
# File 'lib/nuklear/ui/property.rb', line 4 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
4 5 6 |
# File 'lib/nuklear/ui/property.rb', line 4 def min @min end |
#step ⇒ Object
Returns the value of attribute step.
4 5 6 |
# File 'lib/nuklear/ui/property.rb', line 4 def step @step end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/nuklear/ui/property.rb', line 4 def text @text end |
Instance Method Details
#result(x, context) ⇒ Object
21 22 23 24 25 |
# File 'lib/nuklear/ui/property.rb', line 21 def result(x, context) @current = x trigger :changed @last_event = nil end |
#to_command ⇒ Object
17 18 19 |
# File 'lib/nuklear/ui/property.rb', line 17 def to_command [:ui_property, text, min, current, max, step, inc_per_pixel] end |