Class: Code

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dirname, filename, type) ⇒ Code

Returns a new instance of Code.



10
11
12
13
14
15
16
17
18
19
# File 'lib/asker/data/code.rb', line 10

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.



6
7
8
# File 'lib/asker/data/code.rb', line 6

def dirname
  @dirname
end

#featuresObject

Returns the value of attribute features.



7
8
9
# File 'lib/asker/data/code.rb', line 7

def features
  @features
end

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/asker/data/code.rb', line 6

def filename
  @filename
end

#linesObject (readonly)

Returns the value of attribute lines.



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

def lines
  @lines
end

#processObject

Returns the value of attribute process.



7
8
9
# File 'lib/asker/data/code.rb', line 7

def process
  @process
end

#questionsObject (readonly)

Returns the value of attribute questions.



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

def questions
  @questions
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/asker/data/code.rb', line 6

def type
  @type
end

Instance Method Details

#lines_to_s(lines) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/asker/data/code.rb', line 25

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)


21
22
23
# File 'lib/asker/data/code.rb', line 21

def process?
  @process
end