Module: Neruda::IndexOrgGenerator
- Included in:
- Index
- Defined in:
- lib/neruda/index/org_generator.rb
Overview
Embeds methods responsible for generating an org file for a given
index.
Instance Method Summary collapse
- #to_org(index_name = 'index', is_project: false) ⇒ Object (also: #to_s)
- #write_org(index_name) ⇒ Object
Instance Method Details
#to_org(index_name = 'index', is_project: false) ⇒ Object Also known as: to_s
7 8 9 10 11 12 |
# File 'lib/neruda/index/org_generator.rb', line 7 def to_org(index_name = 'index', is_project: false) return project_home_page(index_name) if is_project return if index_name == 'index' [org_header(index_name), org_articles(@index[index_name])].join("\n") end |
#write_org(index_name) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/neruda/index/org_generator.rb', line 15 def write_org(index_name) return unless save? slug = Neruda::OrgFile.slug index_name FileUtils.mkdir 'tags' unless Dir.exist? 'tags' content = to_org index_name orgdest = "tags/#{slug}.org" IO.write(orgdest, content) end |