Class: Udb::ManualChapter

Inherits:
Object
  • Object
show all
Defined in:
lib/udb/obj/manual.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(volume, path) ⇒ ManualChapter

Returns a new instance of ManualChapter.



35
36
37
38
39
40
# File 'lib/udb/obj/manual.rb', line 35

def initialize(volume, path)
  @volume = volume
  @version = volume.version

  @path = Pathname.new path
end

Instance Attribute Details

#pathPathname (readonly)

Returns The relative path to the chapter.

Returns:

  • (Pathname)

    The relative path to the chapter



63
64
65
# File 'lib/udb/obj/manual.rb', line 63

def path
  @path
end

Instance Method Details

#fullpathObject



52
53
54
55
56
# File 'lib/udb/obj/manual.rb', line 52

def fullpath
  raise "Must call repo_path= first" if @repo_path.nil?

  @repo_path / @path
end

#nameObject



42
43
44
# File 'lib/udb/obj/manual.rb', line 42

def name
  @path.basename(".adoc").to_s
end

#repo_path=(path) ⇒ Object



58
59
60
# File 'lib/udb/obj/manual.rb', line 58

def repo_path=(path)
  @repo_path = path
end

#titleObject



46
47
48
49
50
# File 'lib/udb/obj/manual.rb', line 46

def title
  return @title unless @title.nil?

  @title = (Asciidoctor.load File.read(fullpath).scrub).doctitle.encode("US-ASCII")
end