Method: Lbt#num2path
- Defined in:
- lib/lbt/part_typeset.rb
#num2path(n_n_n) ⇒ Object
:nodoc:
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lbt/part_typeset.rb', line 37 def num2path n_n_n return nil unless n_n_n.is_a? String num_pcs = /^(\d+(\.\d+)?)-(\d+(\.\d+)?)-(\d+(\.\d+)?)$/ num_cs = /^(\d+(\.\d+)?)-(\d+(\.\d+)?)$/ num_s = /^(\d+(\.\d+)?)$/ if n_n_n =~ num_pcs path = "part#{$1}/chap#{$3}/sec#{$5}" elsif n_n_n =~ num_cs path = "chap#{$1}/sec#{$3}" elsif n_n_n =~ num_s path = "sec#{$1}" else return nil end srcs = Dir.glob("#{path}.*") return nil if srcs.size != 1 srcs[0] end |