Sha256: 8805c32c160b91fd85b4a809a39aa7adca02ea3c08af1574dfa201e4a38699bd

Contents?: true

Size: 788 Bytes

Versions: 4

Compression:

Stored size: 788 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( engine, 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

4 entries across 4 versions & 1 rubygems

Version Path
gloo-3.7.0 lib/gloo/core/here.rb
gloo-3.6.2 lib/gloo/core/here.rb
gloo-3.6.1 lib/gloo/core/here.rb
gloo-3.6.0 lib/gloo/core/here.rb