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.
9 10 11 12 |
# File 'lib/manpages/man_files.rb', line 9 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.
7 8 9 |
# File 'lib/manpages/man_files.rb', line 7 def man_dir @man_dir end |
Instance Method Details
#man_file_path(file) ⇒ Object
26 27 28 29 |
# File 'lib/manpages/man_files.rb', line 26 def man_file_path(file) man_section = file.extname.match(/\.(\d*)/) @target_dir.join("man#{man_section[1]}", file.basename) end |
#manpages ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/manpages/man_files.rb', line 18 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
14 15 16 |
# File 'lib/manpages/man_files.rb', line 14 def manpages_present? !manpages.empty? end |