lib/openaipoet/poem.rb
# Extracts a poem's formal name included title case
# from a poem file path.
#
# @example
#   path/to/poem/the_tempest.txt => "The Tempest"
#
Extracts a poem's formal name included title case
from a poem file path.
Extracts a poem ' s formal name included title case from a poem file path .
def extract_poem_name(f_path)
      File.basename(f_path, ".txt").split("_").map do |name_split|
        name_split.capitalize
      end.join(" ")
    end
def extract_poem_name ( f_path ) File . basename ( f_path , ".txt" ) . split ( "_" ) . map do | name_split | name_split . capitalize end . join ( " " ) end
Extracts a poem's formal name included title case
from a poem file path.
Extracts a poem ' s formal name included title case from a poem file path .
# Capitalize the first letter of each token in the name
f_path
<not_specific>
example
path/to/poem/the_tempest.txt => "The Tempest"
path / to / poem / the_tempest . txt = > " The Tempest "