Class: Exercise::Template
- Inherits:
-
Object
- Object
- Exercise::Template
- Defined in:
- lib/commands/exercise/command.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(path, project_root_dir) ⇒ Template
constructor
A new instance of Template.
- #relative_path(full_path, root) ⇒ Object
- #rendered_file_path ⇒ Object
Constructor Details
#initialize(path, project_root_dir) ⇒ Template
Returns a new instance of Template.
45 46 47 48 49 50 |
# File 'lib/commands/exercise/command.rb', line 45 def initialize(path, project_root_dir) @full_path = path @dir = parent_directory(path) @path = relative_path(path, dir) @relative_directory = relative_path(dir, project_root_dir) end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
43 44 45 |
# File 'lib/commands/exercise/command.rb', line 43 def dir @dir end |
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
43 44 45 |
# File 'lib/commands/exercise/command.rb', line 43 def full_path @full_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
43 44 45 |
# File 'lib/commands/exercise/command.rb', line 43 def path @path end |
Instance Method Details
#filename ⇒ Object
56 57 58 |
# File 'lib/commands/exercise/command.rb', line 56 def filename File.basename(path) end |
#relative_path(full_path, root) ⇒ Object
60 61 62 |
# File 'lib/commands/exercise/command.rb', line 60 def relative_path(full_path, root) ".#{File.(full_path).gsub(File.(root), '')}" end |
#rendered_file_path ⇒ Object
52 53 54 |
# File 'lib/commands/exercise/command.rb', line 52 def rendered_file_path full_path.gsub(%r{.templates/.*?erb}, filename).gsub('.erb', '') end |