Class: LL::Checklist

Inherits:
Object
  • Object
show all
Defined in:
lib/ll/checklist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_document = nil, name: nil) ⇒ Checklist

Returns a new instance of Checklist.



12
13
14
15
16
# File 'lib/ll/checklist.rb', line 12

def initialize json_document=nil, name: nil
  # TODO: Parse the document
  @name   = name
  @name ||= "Prototypical"
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/ll/checklist.rb', line 3

def name
  @name
end

Class Method Details

.load(dir:) ⇒ Object



5
6
7
8
9
10
# File 'lib/ll/checklist.rb', line 5

def self.load( dir: )
  filepaths = Dir.glob(File.join dir, "checklists/*")
  filepaths.each do | filepath |
    self.new File.read filepath
  end
end

Instance Method Details

#parse_document(json_document) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/ll/checklist.rb', line 18

def parse_document json_document
  raise NotImplementedError
end

#to_hObject



26
27
28
# File 'lib/ll/checklist.rb', line 26

def to_h
  { name: self.name }
end

#to_jsonObject



30
31
32
# File 'lib/ll/checklist.rb', line 30

def to_json
  JSON.dump self.to_hash
end

#to_sObject



22
23
24
# File 'lib/ll/checklist.rb', line 22

def to_s
  "Checklist: #{self.name}"
end