Sha256: db0789d8500decc180405ef1686337f64901e29baa3c2be6b0bcdf0e75398f6f

Contents?: true

Size: 756 Bytes

Versions: 6

Compression:

Stored size: 756 Bytes

Contents

require 'tengine/job'

module Tengine::Job::NamePath

  SEPARATOR = '/'.freeze
  ABSOLUTE_PATH_REGEXP = /^\//.freeze

  class << self
    def absolute?(name_path)
      ABSOLUTE_PATH_REGEXP =~ name_path
    end
  end

  def name_path
    name = respond_to?(:name) ? self.name : self.class.name.split('::').last.underscore
    parent ? "#{parent.name_path}#{SEPARATOR}#{name}" :
      "#{SEPARATOR}#{name}"
  end

  def name_path_until_expansion
    name = respond_to?(:name) ? self.name : self.class.name.split('::').last.underscore
    if self.respond_to?(:was_expansion) && self.was_expansion
      "#{SEPARATOR}#{name}"
    else
      parent ? "#{parent.name_path_until_expansion}#{SEPARATOR}#{name}" :
        "#{SEPARATOR}#{name}"
    end
  end


end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tengine_job-1.1.0 lib/tengine/job/name_path.rb
tengine_job-0.6.13 lib/tengine/job/name_path.rb
tengine_job-0.6.12 lib/tengine/job/name_path.rb
tengine_job-0.6.11 lib/tengine/job/name_path.rb
tengine_job-0.6.10 lib/tengine/job/name_path.rb
tengine_job-0.6.9 lib/tengine/job/name_path.rb