lib/hanamimastery/cli/repositories/episodes.rb in hanamimastery-cli-0.1.0 vs lib/hanamimastery/cli/repositories/episodes.rb in hanamimastery-cli-0.2.0
- old
+ new
@@ -1,9 +1,19 @@
# frozen_string_literal: true
module Hanamimastery
module CLI
+ module Entities
+ class Episode
+ def initialize(content)
+ starts_from = content.lines[1..-1].index("---\n") + 2
+ @content = content.lines[starts_from..-1].join
+ end
+ attr_reader :content
+ end
+ end
+
module Repositories
class Episodes
REPO_PATH = '/Users/Sebastian/Projects/hanamimastery/source'
# Reads the episode file content
#
@@ -17,9 +27,13 @@
File.write(find(id), new_content)
end
def exists?(id)
File.exists?(find(id))
+ end
+
+ def fetch(id)
+ Entities::Episode.new(read(id))
end
private
def file_name(id)