Class: Giblish::ConversionInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/conversion_info.rb

Overview

Base class for bundling together data we always cache for each asciidoc file we come across.

Users are expected to use the derived classes.

Direct Known Subclasses

FailedConversion, SuccessfulConversion

Constant Summary collapse

@@nof_missing_titles =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(converted:, src_node:, dst_node:, dst_top:) ⇒ ConversionInfo

Returns a new instance of ConversionInfo.



29
30
31
32
33
34
35
36
37
# File 'lib/giblish/conversion_info.rb', line 29

def initialize(converted:, src_node:, dst_node:, dst_top:)
  @converted = converted
  @src_node = src_node
  @dst_node = dst_node
  @dst_top = dst_top
  @title = nil

  @src_rel_path = dst_node.relative_path_from(dst_top).dirname / src_node.pathname.basename
end

Instance Attribute Details

#convertedObject (readonly)

Returns the value of attribute converted.



21
22
23
# File 'lib/giblish/conversion_info.rb', line 21

def converted
  @converted
end

#dst_nodeObject (readonly)

Returns the value of attribute dst_node.



21
22
23
# File 'lib/giblish/conversion_info.rb', line 21

def dst_node
  @dst_node
end

#dst_topObject (readonly)

Returns the value of attribute dst_top.



21
22
23
# File 'lib/giblish/conversion_info.rb', line 21

def dst_top
  @dst_top
end

#src_nodeObject (readonly)

Returns the value of attribute src_node.



21
22
23
# File 'lib/giblish/conversion_info.rb', line 21

def src_node
  @src_node
end

#src_rel_pathObject (readonly)

The relative Pathname from the root dir to the src doc Ex Pathname(“my/subdir/file1.adoc”)



25
26
27
# File 'lib/giblish/conversion_info.rb', line 25

def src_rel_path
  @src_rel_path
end

Instance Method Details

#docidObject



50
51
52
# File 'lib/giblish/conversion_info.rb', line 50

def docid
  nil
end

#src_basenameObject

return

a String with the basename of the source file



40
41
42
# File 'lib/giblish/conversion_info.rb', line 40

def src_basename
  @src_node.pathname.basename.to_s
end

#titleObject



44
45
46
47
48
# File 'lib/giblish/conversion_info.rb', line 44

def title
  return @title if @title

  "NO TITLE FOUND (#{@@nof_missing_titles += 1}) !"
end

#to_sObject



54
55
56
# File 'lib/giblish/conversion_info.rb', line 54

def to_s
  "Conversion #{@converted ? "succeeded" : "failed"} - src: #{@src_node.pathname} dst: #{@dst_node.pathname}"
end