Sha256: af534f8e5112aae57cc6a387401b12c05070d558b044a57e730c34243e23354b

Contents?: true

Size: 784 Bytes

Versions: 6

Compression:

Stored size: 784 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 GlooLang
  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

6 entries across 6 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/core/here.rb
gloo-lang-0.9.7 lib/gloo_lang/core/here.rb
gloo-lang-0.9.6 lib/gloo_lang/core/here.rb
gloo-lang-0.9.5 lib/gloo_lang/core/here.rb
gloo-lang-0.9.4 lib/gloo_lang/core/here.rb
gloo-lang-0.9.3 lib/gloo_lang/core/here.rb