Class: Trifle::Docs::Harvester::Conveyor

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/docs/harvester.rb

Direct Known Subclasses

File::Conveyor, Markdown::Conveyor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:, url:, namespace:, cache:) ⇒ Conveyor

Returns a new instance of Conveyor.



363
364
365
366
367
368
369
370
# File 'lib/trifle/docs/harvester.rb', line 363

def initialize(file:, url:, namespace:, cache:)
  @file = file
  @url = url
  @namespace = namespace
  @cache = cache

  preload_cache if cache
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



361
362
363
# File 'lib/trifle/docs/harvester.rb', line 361

def cache
  @cache
end

#fileObject (readonly)

Returns the value of attribute file.



361
362
363
# File 'lib/trifle/docs/harvester.rb', line 361

def file
  @file
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



361
362
363
# File 'lib/trifle/docs/harvester.rb', line 361

def namespace
  @namespace
end

#urlObject (readonly)

Returns the value of attribute url.



361
362
363
# File 'lib/trifle/docs/harvester.rb', line 361

def url
  @url
end

Instance Method Details

#dataObject



376
377
378
379
380
# File 'lib/trifle/docs/harvester.rb', line 376

def data
  @data = nil unless cache

  @data ||= ::File.read(file, encoding: 'utf-8')
end

#preload_cacheObject



372
373
374
# File 'lib/trifle/docs/harvester.rb', line 372

def preload_cache
  # NOTE: harvester is responsible for cache implementation
end