Class: Crusoe::Commands::Read

Inherits:
Object
  • Object
show all
Defined in:
lib/crusoe/commands/read.rb

Constant Summary collapse

DAY_SEPARATOR =
"\n\n".freeze
JOURNAL_FILE_DATE_REGEX =
%r{/(?<date>\d{4}-\d{2}-\d{2})\.md$}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory:, date_range:) ⇒ Read

Returns a new instance of Read.



14
15
16
17
# File 'lib/crusoe/commands/read.rb', line 14

def initialize(directory:, date_range:)
  @directory = directory
  @date_range = date_range
end

Instance Attribute Details

#date_rangeObject (readonly)

Returns the value of attribute date_range.



8
9
10
# File 'lib/crusoe/commands/read.rb', line 8

def date_range
  @date_range
end

#directoryObject (readonly)

Returns the value of attribute directory.



9
10
11
# File 'lib/crusoe/commands/read.rb', line 9

def directory
  @directory
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/crusoe/commands/read.rb', line 19

def to_s
  files.map { File.read(_1) }.join(DAY_SEPARATOR)
end