Class: Trackler::Problem
- Inherits:
-
Object
- Object
- Trackler::Problem
- Defined in:
- lib/trackler/problem.rb
Overview
Problem is a language-independent definition of an exercise.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #blurb ⇒ Object
- #canonical_data_url ⇒ Object
- #deprecated? ⇒ Boolean
- #description ⇒ Object
-
#description_url ⇒ Object
End deprecated methods.
- #exists? ⇒ Boolean
-
#initialize(slug, root, track = NullTrack.new) ⇒ Problem
constructor
A new instance of Problem.
- #json_url ⇒ Object
-
#md_url ⇒ Object
Deprecated methods TODO: remove external references to these methods.
- #metadata_url ⇒ Object
- #name ⇒ Object
- #source ⇒ Object
- #source_markdown ⇒ Object
- #source_url ⇒ Object
- #yaml_url ⇒ Object
Constructor Details
#initialize(slug, root, track = NullTrack.new) ⇒ Problem
Returns a new instance of Problem.
10 11 12 13 14 15 16 17 18 |
# File 'lib/trackler/problem.rb', line 10 def initialize(slug, root, track = NullTrack.new) @slug = slug @root = root @file_root = File.join(root, 'common', 'exercises', self.slug) @repo_root = "https://github.com/exercism/x-common/blob/master/exercises/%s/" % self.slug @metadata = Metadata.for(problem: self, track: track) self.description_object = Description.for(problem: self, track: track) end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/trackler/problem.rb', line 9 def @metadata end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/trackler/problem.rb', line 9 def root @root end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
9 10 11 |
# File 'lib/trackler/problem.rb', line 9 def slug @slug end |
Instance Method Details
#active? ⇒ Boolean
28 29 30 |
# File 'lib/trackler/problem.rb', line 28 def active? exists? && !deprecated? end |
#blurb ⇒ Object
78 79 80 |
# File 'lib/trackler/problem.rb', line 78 def blurb .blurb end |
#canonical_data_url ⇒ Object
70 71 72 |
# File 'lib/trackler/problem.rb', line 70 def canonical_data_url repo_url(canonical_data_file_name) if File.exists?(file_path(canonical_data_file_name, @file_root)) end |
#deprecated? ⇒ Boolean
24 25 26 |
# File 'lib/trackler/problem.rb', line 24 def deprecated? @deprecated ||= File.exists?(file_path(deprecation_file_name, @file_root)) end |
#description ⇒ Object
36 37 38 |
# File 'lib/trackler/problem.rb', line 36 def description description_object.to_s end |
#description_url ⇒ Object
End deprecated methods
66 67 68 |
# File 'lib/trackler/problem.rb', line 66 def description_url description_object.url end |
#exists? ⇒ Boolean
20 21 22 |
# File 'lib/trackler/problem.rb', line 20 def exists? description_object.exists? && .exists? end |
#json_url ⇒ Object
56 57 58 |
# File 'lib/trackler/problem.rb', line 56 def json_url canonical_data_url end |
#md_url ⇒ Object
Deprecated methods TODO: remove external references to these methods. found in: x-api NOT in: exercism.io, cli Anywhere else we need to look? Should this output a warning or raise an error?
52 53 54 |
# File 'lib/trackler/problem.rb', line 52 def md_url description_url end |
#metadata_url ⇒ Object
74 75 76 |
# File 'lib/trackler/problem.rb', line 74 def .url end |
#name ⇒ Object
32 33 34 |
# File 'lib/trackler/problem.rb', line 32 def name slug.split('-').map(&:capitalize).join(' ') end |
#source ⇒ Object
82 83 84 |
# File 'lib/trackler/problem.rb', line 82 def source .source end |
#source_markdown ⇒ Object
40 41 42 43 |
# File 'lib/trackler/problem.rb', line 40 def source_markdown text = [source, markdown_link(source_url)].reject(&:empty?).join(" ") text.empty? ? text : "## Source\n\n#{text}" end |
#source_url ⇒ Object
86 87 88 |
# File 'lib/trackler/problem.rb', line 86 def source_url .source_url end |
#yaml_url ⇒ Object
60 61 62 |
# File 'lib/trackler/problem.rb', line 60 def yaml_url end |