Class: Mortar::Project::Script

Inherits:
Object
  • Object
show all
Defined in:
lib/mortar/project.rb

Direct Known Subclasses

ControlScript, LuigiScript, PigScript, SparkScript

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



213
214
215
# File 'lib/mortar/project.rb', line 213

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



214
215
216
# File 'lib/mortar/project.rb', line 214

def path
  @path
end

Instance Method Details

#codeObject



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_pathObject



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_sObject



233
234
235
# File 'lib/mortar/project.rb', line 233

def to_s
  code
end