Class: Fictive::Bundle
- Inherits:
-
Object
- Object
- Fictive::Bundle
- Defined in:
- lib/fictive/bundle.rb
Instance Attribute Summary collapse
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(files) ⇒ Bundle
constructor
A new instance of Bundle.
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
#documents ⇒ Object (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, ={}) 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 |