Class: Manpages::ManFiles
- Inherits:
-
Object
- Object
- Manpages::ManFiles
- Defined in:
- lib/manpages/man_files.rb
Instance Attribute Summary collapse
-
#man_dir ⇒ Object
readonly
Returns the value of attribute man_dir.
Instance Method Summary collapse
-
#initialize(gem_dir, target_dir = "") ⇒ ManFiles
constructor
A new instance of ManFiles.
- #man_file_path(file) ⇒ Object
- #manpages ⇒ Object
- #manpages_present? ⇒ Boolean
Constructor Details
#initialize(gem_dir, target_dir = "") ⇒ ManFiles
Returns a new instance of ManFiles.
7 8 9 10 |
# File 'lib/manpages/man_files.rb', line 7 def initialize(gem_dir, target_dir = "") @target_dir = Pathname(target_dir) @man_dir = Pathname(File.join(gem_dir, "man")) end |
Instance Attribute Details
#man_dir ⇒ Object (readonly)
Returns the value of attribute man_dir.
5 6 7 |
# File 'lib/manpages/man_files.rb', line 5 def man_dir @man_dir end |
Instance Method Details
#man_file_path(file) ⇒ Object
24 25 26 27 |
# File 'lib/manpages/man_files.rb', line 24 def man_file_path(file) man_section = file.extname.match(/\.(\d*)/) @target_dir.join("man#{man_section[1]}", file.basename) end |
#manpages ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/manpages/man_files.rb', line 16 def manpages return [] unless man_dir.directory? Dir[man_dir.join("**/*")].select do |file| file =~ /\.\d$/ end.map {|file| Pathname.new(file) } end |
#manpages_present? ⇒ Boolean
12 13 14 |
# File 'lib/manpages/man_files.rb', line 12 def manpages_present? !manpages.empty? end |