Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `children' for Dir:Class #3

Open
tablecell opened this issue Sep 4, 2021 · 0 comments
Open

NoMethodError: undefined method `children' for Dir:Class #3

tablecell opened this issue Sep 4, 2021 · 0 comments

Comments

@tablecell
Copy link

ruby 2.4.10p364

src\article_list.rb

  Dir.children('./articles').map do |filename|
     
    config, _article_markdown = read_article filename.split('.')[0]
    read_vars(config) + { 'slug' => filename.split('.')[0] }
  end

NoMethodError: undefined method `delete_suffix' for "title: 'What is miniature painting?'":String

def read_vars(config)
  parsed_config = config.split("\n").map { |line| line.delete_suffix("'").split(': \'') }.to_h
  if parsed_config['tags']
    tags = parsed_config['tags'].split(',').map { |tag| tag.delete_prefix(' ') }.sort
  end
  parsed_config + { 'published' => Date.parse(parsed_config['published']), 'tags' => tags }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant