Module: IsoDoc::ClassUtils
- Included in:
- Common
- Defined in:
- lib/isodoc/class_utils.rb
Instance Method Summary collapse
Instance Method Details
#date_range(date) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/isodoc/class_utils.rb', line 5 def date_range(date) from = date.at(ns("./from")) to = date.at(ns("./to")) on = date.at(ns("./on")) return on.text if on ret = "#{from.text}–" ret += to.text if to ret end |
#ns(xpath) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/isodoc/class_utils.rb', line 15 def ns(xpath) xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1"). gsub(%r{::([a-zA-z])}, "::xmlns:\\1"). gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1"). gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1") end |