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.



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

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



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

def path
  @path
end

Instance Method Details

#fullpathObject



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

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

  @repo_path / @path
end

#nameObject



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

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

#repo_path=(path) ⇒ Object



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

def repo_path=(path)
  @repo_path = path
end

#titleObject



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

def title
  return @title unless @title.nil?

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