Class: List

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

Defined Under Namespace

Classes: Step

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ List

Returns a new instance of List.



4
5
6
7
8
9
10
# File 'lib/checkcheckit/list.rb', line 4

def initialize(file)
  fname = File.basename(file)
  @name = fname.sub(File.extname(fname), '')
  @body = File.read(file)
  @steps = parse_steps(@body)
  @current_step = 0
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



2
3
4
# File 'lib/checkcheckit/list.rb', line 2

def body
  @body
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/checkcheckit/list.rb', line 2

def name
  @name
end

#stepsObject

Returns the value of attribute steps.



2
3
4
# File 'lib/checkcheckit/list.rb', line 2

def steps
  @steps
end

Instance Method Details

#headerObject



12
13
14
15
16
17
# File 'lib/checkcheckit/list.rb', line 12

def header
  return if @body.lines.to_a.empty?
  if line = @body.lines.first.strip
    line if line =~ /#/
  end
end

#to_hObject



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

def to_h
  {name: @name, steps: @steps.map(&:to_h)}
end