Sha256: 54ba218afe7d0c5e68e456ad157a009e91837219e55d287b66f2b0aa1175b86a

Contents?: true

Size: 713 Bytes

Versions: 5

Compression:

Stored size: 713 Bytes

Contents

module QB
  class Role
    attr_accessor :path, :name, :rel_path
    
    def initialize path
      @path = path
      
      @rel_path = if path.to_s.start_with? QB::ROLES_DIR.to_s
        path.sub(QB::ROLES_DIR.to_s + '/', '')
      elsif path.to_s.start_with? Dir.getwd
        path.sub(Dir.getwd + '/', './')
      else
        path
      end
      
      @name = path.to_s.split(File::SEPARATOR).last
    end
    
    def to_s
      @rel_path.to_s
    end
    
    def namespace
      if @name.include? '.'
        @name.split('.').first
      else
        nil
      end
    end
    
    def namespaceless
      @name.split('.', 2).last
    end
    
    def options_key
      @rel_path.to_s
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qb-0.1.13 lib/qb/role.rb
qb-0.1.12 lib/qb/role.rb
qb-0.1.11 lib/qb/role.rb
qb-0.1.10 lib/qb/role.rb
qb-0.1.9 lib/qb/role.rb