Class: Pcoder::SourceCode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SourceCode

Returns a new instance of SourceCode.



11
12
13
14
15
16
17
# File 'lib/pcoder.rb', line 11

def initialize(path)
  @basename = File.basename(path)
  extname = File.extname(path)
  @language_id = to_language_id(extname)
  @task = @basename.split(/[_.]/)[1]
  @body = File.open(path).read
end

Instance Attribute Details

#basenameObject (readonly)

Returns the value of attribute basename.



9
10
11
# File 'lib/pcoder.rb', line 9

def basename
  @basename
end

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/pcoder.rb', line 9

def body
  @body
end

#language_idObject (readonly)

Returns the value of attribute language_id.



9
10
11
# File 'lib/pcoder.rb', line 9

def language_id
  @language_id
end

#taskObject (readonly)

Returns the value of attribute task.



9
10
11
# File 'lib/pcoder.rb', line 9

def task
  @task
end

Instance Method Details

#set_task_option(task) ⇒ Object



19
20
21
# File 'lib/pcoder.rb', line 19

def set_task_option(task)
  @task = task.split("_").last
end