Class: RubyI2C::Device::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_i2c/device/base.rb

Direct Known Subclasses

SI70XX

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter: RubyI2C::Adapter::UnixDevice.new, address: nil) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/ruby_i2c/device/base.rb', line 7

def initialize(adapter: RubyI2C::Adapter::UnixDevice.new, address: nil)
  @adapter = adapter
  @address = address
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



5
6
7
# File 'lib/ruby_i2c/device/base.rb', line 5

def adapter
  @adapter
end

#addressObject (readonly)

Returns the value of attribute address.



5
6
7
# File 'lib/ruby_i2c/device/base.rb', line 5

def address
  @address
end

Instance Method Details

#command(*args) ⇒ Object



13
14
15
# File 'lib/ruby_i2c/device/base.rb', line 13

def command(*args)
  adapter.command address, *args
end

#read(*args) ⇒ Object



18
19
20
# File 'lib/ruby_i2c/device/base.rb', line 18

def read(*args)
  adapter.read address, *args
end

#write(*args) ⇒ Object



23
24
25
# File 'lib/ruby_i2c/device/base.rb', line 23

def write(*args)
  adapter.write address, *args
end