Module: MonomeSerial::SerialCommunicator
- Defined in:
- lib/monome_serial/serial_communicator.rb,
lib/monome_serial/serial_communicator/communicator.rb,
lib/monome_serial/serial_communicator/real_communicator.rb,
lib/monome_serial/serial_communicator/dummy_communicator.rb,
lib/monome_serial/serial_communicator/binary_patterns/series.rb,
lib/monome_serial/serial_communicator/binary_patterns/fourtyh.rb
Defined Under Namespace
Modules: BinaryPatterns Classes: Communicator, DummyCommunicator, RealCommunicator
Class Attribute Summary collapse
-
.suppress_warnings ⇒ Object
Returns the value of attribute suppress_warnings.
Class Method Summary collapse
Class Attribute Details
.suppress_warnings ⇒ Object
Returns the value of attribute suppress_warnings.
4 5 6 |
# File 'lib/monome_serial/serial_communicator.rb', line 4 def suppress_warnings @suppress_warnings end |
Class Method Details
.get_communicator(tty_path) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/monome_serial/serial_communicator.rb', line 7 def self.get_communicator(tty_path) begin raise IOError unless File.exists?(tty_path) raise RuntimeError unless (RUBY_VERSION.split('.').join.to_i >= 191) && (Object.const_defined?("RUBY_ENGINE") && Object.const_get("RUBY_ENGINE") == "ruby") require 'monome_serial/serial_communicator/real_communicator' require 'termios' return RealCommunicator.new(tty_path) rescue IOError puts "Supplied path tty IO file isn't valid, loading up DummyCommunicator instead of a real one" unless suppress_warnings return DummyCommunicator.new rescue RuntimeError puts "Incorrect Ruby version (want MRI Ruby 1.9.1 or higher), loading up DummyCommunicator instead of a real one" unless suppress_warnings return DummyCommunicator.new rescue LoadError puts "Could not load the termios extension. Please install it. Loading up DummyCommunicator instead of a real one" unless suppress_warnings return DummyCommunicator.new end end |