Class: Bookbinder::Section

Inherits:
Struct
  • Object
show all
Defined in:
lib/bookbinder/values/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#at_repo_pathObject

Returns the value of attribute at_repo_path

Returns:

  • (Object)

    the current value of at_repo_path



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def at_repo_path
  @at_repo_path
end

#desired_directory_nameObject

Returns the value of attribute desired_directory_name

Returns:

  • (Object)

    the current value of desired_directory_name



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def desired_directory_name
  @desired_directory_name
end

#desired_subnav_nameObject

Returns the value of attribute desired_subnav_name

Returns:

  • (Object)

    the current value of desired_subnav_name



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def desired_subnav_name
  @desired_subnav_name
end

#full_nameObject

Returns the value of attribute full_name

Returns:

  • (Object)

    the current value of full_name



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def full_name
  @full_name
end

#path_to_repository=(value) ⇒ Object

Sets the attribute path_to_repository

Parameters:

  • value (Object)

    the value to set the attribute path_to_repository to.

Returns:

  • (Object)

    the newly set value



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def path_to_repository=(value)
  @path_to_repository = value
end

#pdf_output_filenameObject

Returns the value of attribute pdf_output_filename

Returns:

  • (Object)

    the current value of pdf_output_filename



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def pdf_output_filename
  @pdf_output_filename
end

#preprocessor_configObject

Returns the value of attribute preprocessor_config

Returns:

  • (Object)

    the current value of preprocessor_config



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def preprocessor_config
  @preprocessor_config
end

#repo_nameObject

Returns the value of attribute repo_name

Returns:

  • (Object)

    the current value of repo_name



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def repo_name
  @repo_name
end

#source_refObject

Returns the value of attribute source_ref

Returns:

  • (Object)

    the current value of source_ref



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def source_ref
  @source_ref
end

Returns the value of attribute subnav_templ

Returns:

  • (Object)

    the current value of subnav_templ



5
6
7
# File 'lib/bookbinder/values/section.rb', line 5

def subnav_templ
  @subnav_templ
end

Instance Method Details

#destination_directoryObject



24
25
26
# File 'lib/bookbinder/values/section.rb', line 24

def destination_directory
  Ingest::DestinationDirectory.new(full_name, desired_directory_name)
end

#path_to_preprocessor_attribute(attr) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/bookbinder/values/section.rb', line 37

def path_to_preprocessor_attribute(attr)
  path_to_repo_dir.join(preprocessor_config[attr]) if preprocessor_config[attr]
rescue NoMethodError => e
  raise Errors::ProgrammerMistake.new(
    "path_to_preprocessor_attribute assumes preprocessor_config is available, got nil.\n" +
    "Original exception:\n\n#{e.inspect}\n\n#{e.backtrace.join("\n")}"
  )
end

#path_to_repo_dirObject



16
17
18
# File 'lib/bookbinder/values/section.rb', line 16

def path_to_repo_dir
  at_repo_path.nil? ? path_to_repository : path_to_repository.join(at_repo_path)
end


28
29
30
31
# File 'lib/bookbinder/values/section.rb', line 28

def subnav
  namespace = destination_directory.to_s.gsub('/', '_')
  {namespace => subnav_name}
end


33
34
35
# File 'lib/bookbinder/values/section.rb', line 33

def subnav_name
  subnav_template || desired_subnav_name || 'default'
end


20
21
22
# File 'lib/bookbinder/values/section.rb', line 20

def subnav_template
  subnav_templ.sub(/^_/, '').sub(/\.erb$/, '') if subnav_templ
end