Class: CIAT::Processors::Copy
- Inherits:
-
Object
- Object
- CIAT::Processors::Copy
- Defined in:
- lib/ciat/processors/copy.rb
Overview
A simple processor that just simply copies the code from one file to the other using the Unix cp
command.
Instance Attribute Summary collapse
-
#light ⇒ Object
Returns the value of attribute light.
Instance Method Summary collapse
- #describe ⇒ Object
- #for_test ⇒ Object
-
#initialize(original, copy) ⇒ Copy
constructor
A new instance of Copy.
- #process(crate) ⇒ Object
- #relevant_elements(crate) ⇒ Object
Constructor Details
#initialize(original, copy) ⇒ Copy
Returns a new instance of Copy.
8 9 10 11 12 |
# File 'lib/ciat/processors/copy.rb', line 8 def initialize(original, copy) @original = original @copy = copy @light = CIAT::TrafficLight.new end |
Instance Attribute Details
#light ⇒ Object
Returns the value of attribute light.
6 7 8 |
# File 'lib/ciat/processors/copy.rb', line 6 def light @light end |
Instance Method Details
#describe ⇒ Object
20 21 22 |
# File 'lib/ciat/processors/copy.rb', line 20 def describe "copy processor" end |
#for_test ⇒ Object
14 15 16 17 18 |
# File 'lib/ciat/processors/copy.rb', line 14 def for_test copy = clone copy.light = light.clone copy end |
#process(crate) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ciat/processors/copy.rb', line 24 def process(crate) if system( "cp '#{crate.element(@original).as_file}' '#{crate.element(@copy).as_file}'") light.green! else light.red! end end |
#relevant_elements(crate) ⇒ Object
32 33 34 |
# File 'lib/ciat/processors/copy.rb', line 32 def relevant_elements(crate) [@original, @copy].map { |e| crate.element(e) } end |