Class: Mortar::Project::Script
- Inherits:
-
Object
- Object
- Mortar::Project::Script
- Defined in:
- lib/mortar/project.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(name, path) ⇒ Script
constructor
A new instance of Script.
- #rel_path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, path) ⇒ Script
Returns a new instance of Script.
216 217 218 219 |
# File 'lib/mortar/project.rb', line 216 def initialize(name, path) @name = name @path = path end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
213 214 215 |
# File 'lib/mortar/project.rb', line 213 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
214 215 216 |
# File 'lib/mortar/project.rb', line 214 def path @path end |
Instance Method Details
#code ⇒ Object
221 222 223 224 225 226 |
# File 'lib/mortar/project.rb', line 221 def code script_file = File.open(@path, "r") script_contents = script_file.read script_file.close script_contents end |
#rel_path ⇒ Object
228 229 230 231 |
# File 'lib/mortar/project.rb', line 228 def rel_path p = Pathname.new(@path).dirname rel_path = p.relative_path_from(Pathname.pwd).to_s end |
#to_s ⇒ Object
233 234 235 |
# File 'lib/mortar/project.rb', line 233 def to_s code end |