Class: PM::Patch
- Inherits:
-
Object
- Object
- PM::Patch
- Defined in:
- lib/patchmaster/patch.rb
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#name ⇒ Object
Returns the value of attribute name.
-
#start_bytes ⇒ Object
Returns the value of attribute start_bytes.
-
#stop_bytes ⇒ Object
Returns the value of attribute stop_bytes.
Instance Method Summary collapse
- #<<(conn) ⇒ Object
-
#initialize(name, start_bytes = nil, stop_bytes = nil) ⇒ Patch
constructor
A new instance of Patch.
- #inputs ⇒ Object
- #running? ⇒ Boolean
-
#start ⇒ Object
Send start_bytes to each connection.
-
#stop ⇒ Object
Send stop_bytes to each connection, then call #stop on each connection.
Constructor Details
#initialize(name, start_bytes = nil, stop_bytes = nil) ⇒ Patch
Returns a new instance of Patch.
7 8 9 10 11 |
# File 'lib/patchmaster/patch.rb', line 7 def initialize(name, start_bytes=nil, stop_bytes=nil) @name, @start_bytes, @stop_bytes = name, start_bytes, stop_bytes @connections = [] @running = false end |
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
5 6 7 |
# File 'lib/patchmaster/patch.rb', line 5 def connections @connections end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/patchmaster/patch.rb', line 5 def name @name end |
#start_bytes ⇒ Object
Returns the value of attribute start_bytes.
5 6 7 |
# File 'lib/patchmaster/patch.rb', line 5 def start_bytes @start_bytes end |
#stop_bytes ⇒ Object
Returns the value of attribute stop_bytes.
5 6 7 |
# File 'lib/patchmaster/patch.rb', line 5 def stop_bytes @stop_bytes end |
Instance Method Details
#<<(conn) ⇒ Object
13 14 15 |
# File 'lib/patchmaster/patch.rb', line 13 def <<(conn) @connections << conn end |
#inputs ⇒ Object
17 18 19 |
# File 'lib/patchmaster/patch.rb', line 17 def inputs @connections.map(&:input).uniq end |
#running? ⇒ Boolean
29 30 31 |
# File 'lib/patchmaster/patch.rb', line 29 def running? @running end |
#start ⇒ Object
Send start_bytes to each connection.
22 23 24 25 26 27 |
# File 'lib/patchmaster/patch.rb', line 22 def start unless @running @connections.each { |conn| conn.start(@start_bytes) } @running = true end end |
#stop ⇒ Object
Send stop_bytes to each connection, then call #stop on each connection.
34 35 36 37 38 39 |
# File 'lib/patchmaster/patch.rb', line 34 def stop if @running @running = false @connections.each { |conn| conn.stop(@stop_bytes) } end end |