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



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

def initialize(name, path)
  @name = name
  @path = path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



208
209
210
# File 'lib/mortar/project.rb', line 208

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



209
210
211
# File 'lib/mortar/project.rb', line 209

def path
  @path
end

Instance Method Details

#codeObject



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_pathObject



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_sObject



228
229
230
# File 'lib/mortar/project.rb', line 228

def to_s
  code
end