Class: Exercism::Assignment
- Inherits:
-
Object
- Object
- Exercism::Assignment
- Defined in:
- lib/exercism/assignment.rb
Instance Attribute Summary collapse
-
#readme ⇒ Object
readonly
Returns the value of attribute readme.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#test_file ⇒ Object
readonly
Returns the value of attribute test_file.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
-
#track ⇒ Object
readonly
Returns the value of attribute track.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Assignment
constructor
A new instance of Assignment.
- #save ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Assignment
Returns a new instance of Assignment.
12 13 14 15 16 17 18 |
# File 'lib/exercism/assignment.rb', line 12 def initialize(attributes) @track = attributes['track'] @slug = attributes['slug'] @readme = attributes['readme'] @test_file = attributes['test_file'] @tests = attributes['tests'] end |
Instance Attribute Details
#readme ⇒ Object (readonly)
Returns the value of attribute readme.
10 11 12 |
# File 'lib/exercism/assignment.rb', line 10 def readme @readme end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
10 11 12 |
# File 'lib/exercism/assignment.rb', line 10 def slug @slug end |
#test_file ⇒ Object (readonly)
Returns the value of attribute test_file.
10 11 12 |
# File 'lib/exercism/assignment.rb', line 10 def test_file @test_file end |
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
10 11 12 |
# File 'lib/exercism/assignment.rb', line 10 def tests @tests end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
10 11 12 |
# File 'lib/exercism/assignment.rb', line 10 def track @track end |
Class Method Details
.save(data) ⇒ Object
4 5 6 7 8 |
# File 'lib/exercism/assignment.rb', line 4 def self.save(data) data['assignments'].each do |attributes| Assignment.new(attributes).save end end |
Instance Method Details
#save ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/exercism/assignment.rb', line 20 def save FileUtils.mkdir_p assignment_dir File.open readme_path, 'w' do |f| f.write readme end File.write tests_path, tests end |