Class: PromptLists::Sublist

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Sublist

Returns a new instance of Sublist.



36
37
38
39
40
41
42
43
44
45
# File 'lib/prompt_lists.rb', line 36

def initialize(file_path)
  @file_path = file_path
  @id = File.basename(file_path, ".yml").gsub(/-/, "_").to_sym
  @content = File.read(@file_path)
  if @content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
    @items = @content[($1.size + $2.size)..-1].split("\n")
    @metadata = YAML.load($1)
  end
  @metadata = (@metadata || {})
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



33
34
35
# File 'lib/prompt_lists.rb', line 33

def id
  @id
end

#itemsObject

Returns the value of attribute items.



34
35
36
# File 'lib/prompt_lists.rb', line 34

def items
  @items
end

#metadataObject

Returns the value of attribute metadata.



34
35
36
# File 'lib/prompt_lists.rb', line 34

def 
  @metadata
end