Class: Code
- Inherits:
-
Object
- Object
- Code
- Defined in:
- lib/asker/code/code.rb
Overview
Contains code data input
Instance Attribute Summary collapse
-
#dirname ⇒ Object
readonly
Returns the value of attribute dirname.
-
#features ⇒ Object
Returns the value of attribute features.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#process ⇒ Object
Returns the value of attribute process.
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #debug ⇒ Object
-
#initialize(dirname, filename, type) ⇒ Code
constructor
A new instance of Code.
- #lines_to_s(lines) ⇒ Object
- #make_questions ⇒ Object
- #process? ⇒ Boolean
Constructor Details
#initialize(dirname, filename, type) ⇒ Code
Returns a new instance of Code.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/asker/code/code.rb', line 11 def initialize(dirname, filename, type) @dirname = dirname @filename = filename @type = type @filepath = File.join(@dirname, @filename) @process = false @features = [] @lines = load(@filepath) @questions = [] @code_ai = CodeAIFactory.get(self) end |
Instance Attribute Details
#dirname ⇒ Object (readonly)
Returns the value of attribute dirname.
7 8 9 |
# File 'lib/asker/code/code.rb', line 7 def dirname @dirname end |
#features ⇒ Object
Returns the value of attribute features.
8 9 10 |
# File 'lib/asker/code/code.rb', line 8 def features @features end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/asker/code/code.rb', line 7 def filename @filename end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
9 10 11 |
# File 'lib/asker/code/code.rb', line 9 def lines @lines end |
#process ⇒ Object
Returns the value of attribute process.
8 9 10 |
# File 'lib/asker/code/code.rb', line 8 def process @process end |
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
9 10 11 |
# File 'lib/asker/code/code.rb', line 9 def questions @questions end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/asker/code/code.rb', line 7 def type @type end |
Instance Method Details
#debug ⇒ Object
40 41 42 43 44 |
# File 'lib/asker/code/code.rb', line 40 def debug out = CodeStringFormatter.to_s(self) p = Project.instance p.verbose out end |
#lines_to_s(lines) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/asker/code/code.rb', line 32 def lines_to_s(lines) out = '' lines.each_with_index do |line, index| out << format("%2d| #{line}\n", (index + 1)) end out end |
#make_questions ⇒ Object
27 28 29 30 |
# File 'lib/asker/code/code.rb', line 27 def make_questions return unless process? @questions += @code_ai.make_questions end |
#process? ⇒ Boolean
23 24 25 |
# File 'lib/asker/code/code.rb', line 23 def process? @process end |