Class: Pcoder::SourceCode
- Inherits:
-
Object
- Object
- Pcoder::SourceCode
- Defined in:
- lib/pcoder.rb
Instance Attribute Summary collapse
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#language_id ⇒ Object
readonly
Returns the value of attribute language_id.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
-
#initialize(path) ⇒ SourceCode
constructor
A new instance of SourceCode.
- #set_task_option(task) ⇒ Object
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
#basename ⇒ Object (readonly)
Returns the value of attribute basename.
9 10 11 |
# File 'lib/pcoder.rb', line 9 def basename @basename end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/pcoder.rb', line 9 def body @body end |
#language_id ⇒ Object (readonly)
Returns the value of attribute language_id.
9 10 11 |
# File 'lib/pcoder.rb', line 9 def language_id @language_id end |
#task ⇒ Object (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 |