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.
211 212 213 214 |
# File 'lib/mortar/project.rb', line 211 def initialize(name, path) @name = name @path = path end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
208 209 210 |
# File 'lib/mortar/project.rb', line 208 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
209 210 211 |
# File 'lib/mortar/project.rb', line 209 def path @path end |
Instance Method Details
#code ⇒ Object
216 217 218 219 220 221 |
# File 'lib/mortar/project.rb', line 216 def code script_file = File.open(@path, "r") script_contents = script_file.read script_file.close script_contents end |
#rel_path ⇒ Object
223 224 225 226 |
# File 'lib/mortar/project.rb', line 223 def rel_path p = Pathname.new(@path).dirname rel_path = p.relative_path_from(Pathname.pwd).to_s end |
#to_s ⇒ Object
228 229 230 |
# File 'lib/mortar/project.rb', line 228 def to_s code end |