class Exercise::Template
Attributes
dir[R]
full_path[R]
path[R]
Public Class Methods
new(path, project_root_dir)
click to toggle source
# 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
Public Instance Methods
filename()
click to toggle source
# File lib/commands/exercise/command.rb, line 56 def filename File.basename(path) end
relative_path(full_path, root)
click to toggle source
# File lib/commands/exercise/command.rb, line 60 def relative_path(full_path, root) ".#{File.expand_path(full_path).gsub(File.expand_path(root), '')}" end
rendered_file_path()
click to toggle source
# File lib/commands/exercise/command.rb, line 52 def rendered_file_path full_path.gsub(%r{.templates/.*?erb}, filename).gsub('.erb', '') end
Private Instance Methods
parent_directory(dir)
click to toggle source
# File lib/commands/exercise/command.rb, line 66 def parent_directory(dir) File.expand_path("#{File.dirname(dir)}/..").to_s end