Class: Dokkit::Resource::Data

Inherits:
Object
  • Object
show all
Includes:
FilenameHelper
Defined in:
lib/dokkit/resource/data.rb

Overview

Data are immutable resources. Data files are copied from source directory (usually doc/data) to output directory. No rendering process occurs during copying.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FilenameHelper

#filename_helper

Constructor Details

#initialize(source_fn, configuration = { :data_dir => 'doc/data', :output_dir => 'output' }) ⇒ Data

A Data instance is initialized with the source filename and a configuration hash containing data and output directory.



21
22
23
24
# File 'lib/dokkit/resource/data.rb', line 21

def initialize(source_fn, configuration = { :data_dir => 'doc/data', :output_dir => 'output' } )
  @source_fn = source_fn
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



18
19
20
# File 'lib/dokkit/resource/data.rb', line 18

def configuration
  @configuration
end

#source_fnObject (readonly)

Returns the value of attribute source_fn.



18
19
20
# File 'lib/dokkit/resource/data.rb', line 18

def source_fn
  @source_fn
end

Instance Method Details

#target_fnObject

Return the filename of the target data file.

Example:

target_fn = Data.new(‘doc/data/data_1’).target_fn #=> ‘output/data_1’



31
32
33
# File 'lib/dokkit/resource/data.rb', line 31

def target_fn
  filename_helper(source_fn, @configuration[:data_dir], @configuration[:output_dir], '')        
end