Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/babelyoda/file.rb
Class Method Summary collapse
- .localized(filename, language) ⇒ Object
- .lproj_part(filename) ⇒ Object
- .omit_lproj(filename) ⇒ Object
Class Method Details
.localized(filename, language) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/babelyoda/file.rb', line 13 def self.localized(filename, language) if lproj_part(filename) File.join(filename.split('/').map { |p| p.match(/^.*\.lproj$/) ? "#{language}.lproj" : p }) else File.join(File.dirname(filename), "#{language}.lproj", File.basename(filename)) end end |
.lproj_part(filename) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/babelyoda/file.rb', line 2 def self.lproj_part(filename) filename.split('/').each do |part| return part if part =~ /^.*\.lproj$/ end nil end |
.omit_lproj(filename) ⇒ Object
9 10 11 |
# File 'lib/babelyoda/file.rb', line 9 def self.omit_lproj(filename) File.join(filename.split('/').delete_if { |p| p.match(/^.*\.lproj$/) }) end |