Class: Udb::ManualVolume

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, version) ⇒ ManualVolume

Returns a new instance of ManualVolume.



71
72
73
74
# File 'lib/udb/obj/manual.rb', line 71

def initialize(data, version)
  @data = data
  @version = version
end

Instance Attribute Details

#versionManualVersion (readonly)

Returns The version this volume belongs to.

Returns:



67
68
69
# File 'lib/udb/obj/manual.rb', line 67

def version
  @version
end

Instance Method Details

#cfg_archObject



69
# File 'lib/udb/obj/manual.rb', line 69

def cfg_arch = version.cfg_arch

#chapter(name) ⇒ Object



89
# File 'lib/udb/obj/manual.rb', line 89

def chapter(name) = chapters.find { |c| c.name == name }

#chaptersObject



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/udb/obj/manual.rb', line 76

def chapters
  return @chapters unless @chapters.nil?

  @chapters = []
  return @chapters if @data["chapters"].nil?

  @data["chapters"].each do |chapter_path|
    @chapters << ManualChapter.new(self, chapter_path)
  end

  @chapters
end

#extensionsArray<ExtensionVersion>

Returns Array of extension versions in this volume.

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/udb/obj/manual.rb', line 94

def extensions
  return @extensions unless @extensions.nil?

  @extensions = []
  return @extensions if @data["extensions"].nil?

  @data["extensions"].each do |ext_hsh|
    ext_obj = cfg_arch.extension(ext_hsh["name"])
    if ext_obj.nil?
      warn "Extension '#{ext_hsh['name']}' is not in the database"
      next
    end

    ext_ver = ExtensionVersion.new(ext_hsh["name"], ext_hsh["version"], cfg_arch)
    unless ext_obj.versions.any? { |known_ver| known_ver == ext_ver }
      warn "Extension '#{ext_hsh['name']}', version '#{ext_hsh['version']}' is not defined in the database"
      next
    end

    @extensions << ext_ver
  end
  @extensions
end

#repo_path=(path) ⇒ Object



118
119
120
121
# File 'lib/udb/obj/manual.rb', line 118

def repo_path=(path)
  @repo_path = path
  chapters.each { |c| c.repo_path = path }
end

#titleObject



91
# File 'lib/udb/obj/manual.rb', line 91

def title = @data["title"]