Class: LCDProc::Widgets::Title
- Inherits:
-
Object
- Object
- LCDProc::Widgets::Title
- Includes:
- LCDProc::Widget
- Defined in:
- lib/lcdproc/widgets/title.rb
Constant Summary collapse
- @@widget_count =
0
Instance Attribute Summary collapse
-
#title_text ⇒ Object
Returns the value of attribute title_text.
Attributes included from LCDProc::Widget
Instance Method Summary collapse
-
#initialize(id = "TitleWidget_#{@@widget_count}", text = "Title") ⇒ Title
constructor
Creates a new Title widget which gets displayed at the top of 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 = "TitleWidget_#{@@widget_count}", text = "Title") ⇒ Title
Creates a new Title widget which gets displayed at the top of the screen
-
:id
- A unique string which identifies this widget. Defaults to “TitleWidget_” + a sequence number. -
:text
- The text that you wish to display as the title. Default to “Title”.
Example:
w = Title.new
or
w = Title.new( 'Test', 'My Wonderful Title' )
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lcdproc/widgets/title.rb', line 52 def initialize( id = "TitleWidget_#{@@widget_count}", text = "Title" ) if id.nil? id = "TitleWidget_#{@@widget_count}" end @id = id @type = :title @screen = nil @visible = false @title_text = text @@widget_count += 1 end |
Instance Attribute Details
#title_text ⇒ Object
Returns the value of attribute title_text.
35 36 37 |
# File 'lib/lcdproc/widgets/title.rb', line 35 def title_text @title_text end |
Instance Method Details
#update ⇒ Object
Sends to command to the LCDd server to update the widget on screen
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/lcdproc/widgets/title.rb', line 69 def update if @screen response = @screen.client.send_command( Command.new( "widget_set #{@screen.id} #{self.id} \"#{@title_text}\"" ) ) 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 |