Sha256: cf3b00601f7eb2b4d89fe0052d6a3ddba27173315c0c4266e725f2331e53b3eb

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 Bytes

Contents

require_relative "finds_foreign_caller"

module CutePrint
  class Location

    extend FindsForeignCaller

    def self.find
      path, line_number = nearest_foreign_caller.split(':')
      line_number = line_number.to_i
      new(path, line_number)
    end

    def initialize(path, line_number)
      @path = path
      @line_number = line_number
    end

    def format(template)
      template % {
        path: @path,
        filename: filename,
        line_number: @line_number,
      }
    end

    private

    def filename
      File.basename(@path)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cute_print-0.3.0 lib/cute_print/location.rb
cute_print-0.2.0 lib/cute_print/location.rb