Class: PromptLists::Sublist
- Inherits:
-
Object
- Object
- PromptLists::Sublist
- Defined in:
- lib/prompt_lists.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
Returns the value of attribute items.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Sublist
constructor
A new instance of Sublist.
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
#id ⇒ Object (readonly)
Returns the value of attribute id.
33 34 35 |
# File 'lib/prompt_lists.rb', line 33 def id @id end |
#items ⇒ Object
Returns the value of attribute items.
34 35 36 |
# File 'lib/prompt_lists.rb', line 34 def items @items end |
#metadata ⇒ Object
Returns the value of attribute metadata.
34 35 36 |
# File 'lib/prompt_lists.rb', line 34 def @metadata end |