Class: GreenDay::Task
- Inherits:
-
Object
- Object
- GreenDay::Task
- Defined in:
- lib/green_day/task.rb
Defined Under Namespace
Classes: SampleAnswer
Instance Attribute Summary collapse
-
#contest_name ⇒ Object
readonly
Returns the value of attribute contest_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #create_file ⇒ Object
- #create_spec_file ⇒ Object
- #file_name ⇒ Object
-
#initialize(name, path, contest_name) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(name, path, contest_name) ⇒ Task
Returns a new instance of Task.
8 9 10 11 12 |
# File 'lib/green_day/task.rb', line 8 def initialize(name, path, contest_name) @name = name @path = path @contest_name = contest_name end |
Instance Attribute Details
#contest_name ⇒ Object (readonly)
Returns the value of attribute contest_name.
6 7 8 |
# File 'lib/green_day/task.rb', line 6 def contest_name @contest_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/green_day/task.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/green_day/task.rb', line 6 def path @path end |
Instance Method Details
#create_file ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/green_day/task.rb', line 14 def create_file template = if File.exist?(GreenDay::TEMPLATE_FILE_PATH) File.read(GreenDay::TEMPLATE_FILE_PATH) end File.write(file_name, template) end |
#create_spec_file ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/green_day/task.rb', line 26 def create_spec_file test_content = TestBuilder.build_test( file_name, sample_answers ) File.write("#{contest_name}/spec/#{name}_spec.rb", test_content) end |
#file_name ⇒ Object
22 23 24 |
# File 'lib/green_day/task.rb', line 22 def file_name "#{contest_name}/#{name}.rb" end |