Class: Exercism::Assignment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Assignment

Returns a new instance of Assignment.



6
7
8
9
10
11
12
# File 'lib/exercism/assignment.rb', line 6

def initialize(attributes)
  @track = attributes['track']
  @slug = attributes['slug']
  @readme = attributes['readme']
  @testfile = attributes['testfile']
  @tests = attributes['tests']
end

Instance Attribute Details

#readmeObject (readonly)

Returns the value of attribute readme.



4
5
6
# File 'lib/exercism/assignment.rb', line 4

def readme
  @readme
end

#slugObject (readonly)

Returns the value of attribute slug.



4
5
6
# File 'lib/exercism/assignment.rb', line 4

def slug
  @slug
end

#testfileObject (readonly)

Returns the value of attribute testfile.



4
5
6
# File 'lib/exercism/assignment.rb', line 4

def testfile
  @testfile
end

#testsObject (readonly)

Returns the value of attribute tests.



4
5
6
# File 'lib/exercism/assignment.rb', line 4

def tests
  @tests
end

#trackObject (readonly)

Returns the value of attribute track.



4
5
6
# File 'lib/exercism/assignment.rb', line 4

def track
  @track
end

Instance Method Details

#saveObject



14
15
16
17
18
19
20
# File 'lib/exercism/assignment.rb', line 14

def save
  FileUtils.mkdir_p assignment_dir
  File.open readme_path, 'w' do |f|
    f.write readme
  end
  File.write tests_path, tests
end