Class: LgLcd::Connection
- Inherits:
-
Object
- Object
- LgLcd::Connection
- Defined in:
- lib/lg-lcd/lib.rb,
lib/lg-lcd/connection.rb
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(name) ⇒ Connection
constructor
A new instance of Connection.
- #open(&block) ⇒ Object
Constructor Details
#initialize(name) ⇒ Connection
Returns a new instance of Connection.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/lg-lcd/lib.rb', line 225 def initialize name @ctx = Lib::ConnectionContext.new @ctx[:app_friendly_name] = string_pointer(name) @ctx[:is_persistent] = false @ctx[:is_autostartable] = false @ctx[:connection] = Lib::LGLCD_INVALID_CONNECTION raise "Connecting failed" unless Lib::LGLCD_RET_OK == Lib.connect(@ctx) begin yield(self) ensure Lib.disconnect(connection) end end |
Instance Method Details
#connection ⇒ Object
241 242 243 |
# File 'lib/lg-lcd/lib.rb', line 241 def connection return @ctx[:connection] end |
#open(&block) ⇒ Object
245 246 247 |
# File 'lib/lg-lcd/lib.rb', line 245 def open &block return Open.new(connection, &block) end |