Skip to content

Commit a88b8e6

Browse files
committed
Merge pull request #1 from joshkrueger/code_cleanup
Updates method definitions to use a consistent style
2 parents 5cd8d89 + 257727f commit a88b8e6

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lib/em-serialport/connection.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module EventMachine
22
class Connection
3-
def on_data(&blk); @on_data = blk; end
3+
def on_data(&blk)
4+
@on_data = blk
5+
end
46

57
def trigger_on_data(data)
68
@on_data.call(data) if @on_data

lib/em-serialport/serial_port.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ class << self
33
def connect_serial(dev, baud, databits, stopbits, parity)
44
SerialPort.open(dev, baud, databits, stopbits, parity).uuid
55
end
6-
end
76

8-
def EventMachine::open_serial(dev, baud, databits, stopbits, parity, handler=nil)
9-
klass = if(handler and handler.is_a?(Class))
10-
handler
11-
else
12-
Class.new(Connection) {handler and include handler}
7+
def open_serial(dev, baud, databits, stopbits, parity, handler=nil)
8+
klass = if(handler and handler.is_a?(Class))
9+
handler
10+
else
11+
Class.new(Connection) {handler and include handler}
12+
end
13+
uuid = connect_serial(dev, baud, databits, stopbits, parity)
14+
connection = klass.new uuid
15+
@conns[uuid] = connection
16+
block_given? and yield connection
17+
connection
1318
end
14-
uuid = connect_serial(dev, baud, databits, stopbits, parity)
15-
connection = klass.new uuid
16-
@conns[uuid] = connection
17-
block_given? and yield connection
18-
connection
1919
end
2020

2121
class SerialPort < StreamObject

0 commit comments

Comments
 (0)