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
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Instance Method Summary collapse
- #description ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(slug, root) ⇒ Problem
constructor
A new instance of Problem.
- #json_url ⇒ Object
- #md_url ⇒ Object
- #name ⇒ Object
- #source_markdown ⇒ Object
- #yaml_url ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/trackler/problem.rb', line 6 def root @root end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
6 7 8 |
# File 'lib/trackler/problem.rb', line 6 def slug @slug end |
Instance Method Details
#description ⇒ Object
20 21 22 |
# File 'lib/trackler/problem.rb', line 20 def description @description ||= File.read(filepath(md)) end |
#exists? ⇒ Boolean
12 13 14 |
# File 'lib/trackler/problem.rb', line 12 def exists? !!md && !!yaml end |
#json_url ⇒ Object
38 39 40 |
# File 'lib/trackler/problem.rb', line 38 def json_url repo_url(json) if !!json end |
#md_url ⇒ Object
34 35 36 |
# File 'lib/trackler/problem.rb', line 34 def md_url repo_url(md) end |
#name ⇒ Object
16 17 18 |
# File 'lib/trackler/problem.rb', line 16 def name @name ||= slug.split('-').map(&:capitalize).join(' ') end |
#source_markdown ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/trackler/problem.rb', line 24 def source_markdown body = source.empty? ? "" : "%s" % source url = source_url.empty? ? "" : "[%s](%s)" % [source_url, source_url] if url.empty? && body.empty? "" else "## Source\n\n" + [body, url].reject(&:empty?).join(" ") end end |
#yaml_url ⇒ Object
42 43 44 |
# File 'lib/trackler/problem.rb', line 42 def yaml_url repo_url(yaml) end |