Class: List
- Inherits:
-
Object
- Object
- List
- Defined in:
- lib/checkcheckit/list.rb
Defined Under Namespace
Classes: Step
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(file) ⇒ List
constructor
A new instance of List.
- #to_h ⇒ Object
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
#body ⇒ Object
Returns the value of attribute body.
2 3 4 |
# File 'lib/checkcheckit/list.rb', line 2 def body @body end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/checkcheckit/list.rb', line 2 def name @name end |
#steps ⇒ Object
Returns the value of attribute steps.
2 3 4 |
# File 'lib/checkcheckit/list.rb', line 2 def steps @steps end |
Instance Method Details
#header ⇒ Object
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_h ⇒ Object
19 20 21 |
# File 'lib/checkcheckit/list.rb', line 19 def to_h {name: @name, steps: @steps.map(&:to_h)} end |