Class: Code

Inherits:
Object
  • Object
show all
Defined in:
lib/asker/data/code.rb

Overview

Code data object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dirname, filename, type) ⇒ Code

Initialize Code object

Parameters:

  • dirname (String)
  • filename (String)
  • type (String)


18
19
20
21
22
23
24
25
26
27
# File 'lib/asker/data/code.rb', line 18

def initialize(dirname, filename, type)
  @dirname = dirname
  @filename = filename
  @type = type
  @filepath = File.join(@dirname, @filename)
  @process = false
  @features = []
  @lines = load(@filepath)
  @questions = []
end

Instance Attribute Details

#dirnameObject (readonly)

Returns the value of attribute dirname.



9
10
11
# File 'lib/asker/data/code.rb', line 9

def dirname
  @dirname
end

#featuresObject

Returns the value of attribute features.



10
11
12
# File 'lib/asker/data/code.rb', line 10

def features
  @features
end

#filenameObject (readonly)

Returns the value of attribute filename.



9
10
11
# File 'lib/asker/data/code.rb', line 9

def filename
  @filename
end

#linesObject (readonly)

Returns the value of attribute lines.



11
12
13
# File 'lib/asker/data/code.rb', line 11

def lines
  @lines
end

#processObject

Returns the value of attribute process.



10
11
12
# File 'lib/asker/data/code.rb', line 10

def process
  @process
end

#questionsObject (readonly)

Returns the value of attribute questions.



11
12
13
# File 'lib/asker/data/code.rb', line 11

def questions
  @questions
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/asker/data/code.rb', line 9

def type
  @type
end

Instance Method Details

#debugObject



41
42
43
# File 'lib/asker/data/code.rb', line 41

def debug
  Logger.verbose CodeStringFormatter.to_s(self)
end

#lines_to_s(lines) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/asker/data/code.rb', line 33

def lines_to_s(lines)
  out = ''
  lines.each_with_index do |line, index|
    out << format("%2d| #{line}\n", (index + 1))
  end
  out
end

#process?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/asker/data/code.rb', line 29

def process?
  @process
end