Class: LL::Checklist
- Inherits:
-
Object
- Object
- LL::Checklist
- Defined in:
- lib/ll/checklist.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(json_document = nil, name: nil) ⇒ Checklist
constructor
A new instance of Checklist.
- #parse_document(json_document) ⇒ Object
- #to_h ⇒ Object
- #to_json ⇒ Object
- #to_s ⇒ Object
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
#name ⇒ Object (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
18 19 20 |
# File 'lib/ll/checklist.rb', line 18 def parse_document json_document raise NotImplementedError end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/ll/checklist.rb', line 26 def to_h { name: self.name } end |
#to_json ⇒ Object
30 31 32 |
# File 'lib/ll/checklist.rb', line 30 def to_json JSON.dump self.to_hash end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/ll/checklist.rb', line 22 def to_s "Checklist: #{self.name}" end |