Class: Fictive::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/fictive/bundle.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files) ⇒ Bundle

Returns a new instance of Bundle.



19
20
21
# File 'lib/fictive/bundle.rb', line 19

def initialize(files)
  @documents = files.map { |file| file.read }.freeze
end

Instance Attribute Details

#documentsObject (readonly)

Returns the value of attribute documents.



17
18
19
# File 'lib/fictive/bundle.rb', line 17

def documents
  @documents
end

Class Method Details

.import(path, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fictive/bundle.rb', line 3

def self.import(path, options={})
  bundle_path = Pathname.new(path)

  if bundle_path.directory?
    files = bundle_path.children.select { |file| file.extname == '.txt' }
  elsif bundle_path.exist?
    files = [bundle_path] if bundle_path.extname == '.txt'
  else
    # File not found
  end

  self.new(files)
end