Class: XOSD

Inherits:
Object
  • Object
show all
Defined in:
lib/xosd/xosd.rb

Defined Under Namespace

Classes: XOSDError

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ XOSD

Returns a new instance of XOSD.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xosd/xosd.rb', line 7

def initialize(opts={})
  @osd = XOSD_Bindings.xosd_create opts[:lines]||1
  handle(-1) if @osd.null?
  ObjectSpace.define_finalizer(self, self.class.method(:finalize).to_proc)
  self.bar_length = opts[:bar_length] if opts[:bar_length]
  self.position = opts[:position] if opts[:position]
  self.align = opts[:align] if opts[:align]
  self.colour = opts[:colour] if opts[:colour]
  self.font = opts[:font] if opts[:font]
  self.horizontal_offset = opts[:horizontal_offset] if opts[:horizontal_offset]
  self.vertical_offset = opts[:vertical_offset] if opts[:vertical_offset]
  self.outline_offset = opts[:outline_offset] if opts[:outline_offset]
  self.outline_colour = opts[:outline_colour] if opts[:outline_colour]
  self.shadow_offset = opts[:shadow_offset] if opts[:shadow_offset]
  self.shadow_colour = opts[:shadow_colour] if opts[:shadow_colour]
  self.timeout = opts[:timeout] if opts[:timeout]
end

Instance Method Details

#align=(align) ⇒ Object

:left, :center, :right



72
73
74
# File 'lib/xosd/xosd.rb', line 72

def align=(align)
  handle(XOSD_Bindings.xosd_set_align(@osd, align))
end

#bar_length=(length) ⇒ Object



100
101
102
# File 'lib/xosd/xosd.rb', line 100

def bar_length=(length)
  handle(XOSD_Bindings.xosd_set_bar_length(@osd, length))
end

#colour=(colour) ⇒ Object



58
59
60
# File 'lib/xosd/xosd.rb', line 58

def colour=(colour)
  handle(XOSD_Bindings.xosd_set_colour(@osd, colour))
end

#display(string, opts = {line: 0}) ⇒ Object



30
31
32
# File 'lib/xosd/xosd.rb', line 30

def display(string, opts={line: 0})
  handle(XOSD_Bindings.xosd_display(@osd, opts[:line], :xosd_command, :string, :string, string))
end

#display_bar(percentage, opts = {line: 0}) ⇒ Object



34
35
36
# File 'lib/xosd/xosd.rb', line 34

def display_bar(percentage, opts={line: 0})
  handle(XOSD_Bindings.xosd_display(@osd, opts[:line], :xosd_command, :percentage, :int, percentage))
end

#display_slider(percentage, opts = {line: 0}) ⇒ Object



38
39
40
# File 'lib/xosd/xosd.rb', line 38

def display_slider(percentage, opts={line: 0})
  handle(XOSD_Bindings.xosd_display(@osd, opts[:line], :xosd_command, :slider, :int, percentage))
end

#font=(font) ⇒ Object



62
63
64
# File 'lib/xosd/xosd.rb', line 62

def font=(font)
  handle(XOSD_Bindings.xosd_set_font(@osd, font))
end

#hideObject



50
51
52
# File 'lib/xosd/xosd.rb', line 50

def hide
  handle(XOSD_Bindings.xosd_hide(@osd))
end

#horizontal_offset=(offset) ⇒ Object



76
77
78
# File 'lib/xosd/xosd.rb', line 76

def horizontal_offset=(offset)
  handle(XOSD_Bindings.xosd_set_horizontal_offset(@osd, offset))
end

#linesObject



104
105
106
# File 'lib/xosd/xosd.rb', line 104

def lines
  XOSD_Bindings.xosd_get_number_lines(@osd)
end

#on_screen?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/xosd/xosd.rb', line 42

def on_screen?
  XOSD_Bindings.xosd_is_onscreen(@osd) != 0
end

#outline_colour=(colour) ⇒ Object



88
89
90
# File 'lib/xosd/xosd.rb', line 88

def outline_colour=(colour)
  handle(XOSD_Bindings.xosd_set_outline_colour(@osd, colour))
end

#outline_offset=(offset) ⇒ Object



84
85
86
# File 'lib/xosd/xosd.rb', line 84

def outline_offset=(offset)
  handle(XOSD_Bindings.xosd_set_outline_offset(@osd, offset))
end

#position=(position) ⇒ Object

:top, :middle, :bottom



67
68
69
# File 'lib/xosd/xosd.rb', line 67

def position=(position)
  handle(XOSD_Bindings.xosd_set_pos(@osd, position))
end

#scroll_by(lines) ⇒ Object



112
113
114
# File 'lib/xosd/xosd.rb', line 112

def scroll_by(lines)
  handle(XOSD_Bindings.xosd_scroll(@osd, lines))
end

#shadow_colour=(colour) ⇒ Object



96
97
98
# File 'lib/xosd/xosd.rb', line 96

def shadow_colour=(colour)
  handle(XOSD_Bindings.xosd_set_shadow_colour(@osd, colour))
end

#shadow_offset=(offset) ⇒ Object



92
93
94
# File 'lib/xosd/xosd.rb', line 92

def shadow_offset=(offset)
  handle(XOSD_Bindings.xosd_set_shadow_offset(@osd, offset))
end

#showObject



54
55
56
# File 'lib/xosd/xosd.rb', line 54

def show
  handle(XOSD_Bindings.xosd_show(@osd))
end

#teardownObject



25
26
27
28
# File 'lib/xosd/xosd.rb', line 25

def teardown
  handle(XOSD_Bindings.xosd_destroy(@osd)) if @osd && !@osd.null?
  @osd = nil
end

#timeout=(period) ⇒ Object



108
109
110
# File 'lib/xosd/xosd.rb', line 108

def timeout=(period)
  handle(XOSD_Bindings.xosd_set_timeout(@osd, period))
end

#vertical_offset=(offset) ⇒ Object



80
81
82
# File 'lib/xosd/xosd.rb', line 80

def vertical_offset=(offset)
  handle(XOSD_Bindings.xosd_set_vertical_offset(@osd, offset))
end

#wait_until_no_displayObject



46
47
48
# File 'lib/xosd/xosd.rb', line 46

def wait_until_no_display
  handle(XOSD_Bindings.xosd_wait_until_no_display(@osd))
end