Class: LCDProc::Widgets::Num
- Inherits:
-
Object
- Object
- LCDProc::Widgets::Num
- Includes:
- LCDProc::Widget
- Defined in:
- lib/lcdproc/widgets/num.rb
Constant Summary collapse
- @@widget_count =
0
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
-
#x ⇒ Object
Returns the value of attribute x.
Attributes included from LCDProc::Widget
Instance Method Summary collapse
-
#initialize(id = "NumWidget_#{@@widget_count}", num = 1, col = 1) ⇒ Num
constructor
Creates a new Num widget which can then be displayed anywhere on the screen.
-
#update ⇒ Object
Sends to command to the LCDd server to update the widget on screen.
Methods included from LCDProc::Widget
add_support, #attach_to, #detach, #hide, new, #show, supported_types
Constructor Details
#initialize(id = "NumWidget_#{@@widget_count}", num = 1, col = 1) ⇒ Num
Creates a new Num widget which can then be displayed anywhere on the screen.
-
:id
- A unique string which identifies this widget. Defaults to “NumWidget_” + a sequence number. -
:num
- The number that you wish to display on the screen. Default to 1. -
:col
- The column in which you wish to display the num on screen. Defaults to 1.
Example:
w = Num.new
or
w = Num.new( 'Clock-Hour', 8, 1 )
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lcdproc/widgets/num.rb', line 53 def initialize( id = "NumWidget_#{@@widget_count}", num = 1, col = 1 ) if id.nil? id = "NumWidget_#{@@widget_count}" end @id = id @type = :num @screen = nil @visible = false @number = num @x = col @@widget_count += 1 end |
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
35 36 37 |
# File 'lib/lcdproc/widgets/num.rb', line 35 def number @number end |
#x ⇒ Object
Returns the value of attribute x.
35 36 37 |
# File 'lib/lcdproc/widgets/num.rb', line 35 def x @x end |
Instance Method Details
#update ⇒ Object
Sends to command to the LCDd server to update the widget on screen
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/lcdproc/widgets/num.rb', line 71 def update if @screen response = @screen.client.send_command( Command.new( "widget_set #{@screen.id} #{self.id} #{@x} #{@number}" ) ) if response.successful? @screen.client.( "Widget '#{@id}' was successfully updated" ) return true else @screen.client.( "Error: Widget '#{@id}' was NOT successfully updated (#{response.})" ) return true end else @screen.client.( "Error: Cannot update Widget '#{@id}' until it is attached to a screen" ) return false end end |