Class: Exercism::Assignment

Inherits:
Object
  • Object
show all
Defined in:
lib/exercism/assignment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#readmeObject (readonly)

Returns the value of attribute readme.



10
11
12
# File 'lib/exercism/assignment.rb', line 10

def readme
  @readme
end

#slugObject (readonly)

Returns the value of attribute slug.



10
11
12
# File 'lib/exercism/assignment.rb', line 10

def slug
  @slug
end

#test_fileObject (readonly)

Returns the value of attribute test_file.



10
11
12
# File 'lib/exercism/assignment.rb', line 10

def test_file
  @test_file
end

#testsObject (readonly)

Returns the value of attribute tests.



10
11
12
# File 'lib/exercism/assignment.rb', line 10

def tests
  @tests
end

#trackObject (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

#saveObject



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