Sha256: bc989ea47051e7f2bfb13b704415de1922c8dd1106cf30d4fa35833546a0b22b

Contents?: true

Size: 618 Bytes

Versions: 2

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

module Lrama
  class Lexer
    class GrammarFile
      class Text < String
        def inspect
          length <= 50 ? super : "#{self[0..47]}...".inspect
        end
      end

      attr_reader :path, :text

      def initialize(path, text)
        @path = path
        @text = Text.new(text).freeze
      end

      def inspect
        "<#{self.class}: @path=#{path}, @text=#{text.inspect}>"
      end

      def ==(other)
        self.class == other.class &&
        self.path == other.path
      end

      def lines
        @lines ||= text.split("\n")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lrama-0.6.11 lib/lrama/lexer/grammar_file.rb
lrama-0.6.10 lib/lrama/lexer/grammar_file.rb