Sha256: 7dbb6003780c446ed4d3141b13335bbb5398871be4db8586b4383a38d12668c6

Contents?: true

Size: 780 Bytes

Versions: 11

Compression:

Stored size: 780 Bytes

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# Here helper class,
# used to resolve relative referencing.
#

module Gloo
  module Core
    class Here

      HERE = '^'.freeze

      #
      # Does the pathname start with here reference?
      #
      def self.includes_here_ref?( elements )
        return elements.first.start_with?( HERE )
      end

      #
      # Expand here reference if present.
      #
      def self.expand_here( pn )
        target = $engine.exec_env.here_obj

        here = pn.elements.first
        remainder = pn.elements[ 1..-1 ].join( '.' )

        here.length.times { target = target.parent }
        pn.set_to "#{target.pn}.#{remainder}"
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gloo-0.8.0 lib/gloo/core/here.rb
gloo-0.7.7 lib/gloo/core/here.rb
gloo-0.7.6 lib/gloo/core/here.rb
gloo-0.7.5 lib/gloo/core/here.rb
gloo-0.7.4 lib/gloo/core/here.rb
gloo-0.7.3 lib/gloo/core/here.rb
gloo-0.7.2 lib/gloo/core/here.rb
gloo-0.7.1 lib/gloo/core/here.rb
gloo-0.7.0 lib/gloo/core/here.rb
gloo-0.6.1 lib/gloo/core/here.rb
gloo-0.6.0 lib/gloo/core/here.rb