Sha256: 05e75417a5a39d7f6f27ec2c77eccca359481471a7ea327cb8d0e54d741501ea

Contents?: true

Size: 587 Bytes

Versions: 4

Compression:

Stored size: 587 Bytes

Contents

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

4 entries across 4 versions & 1 rubygems

Version Path
lrama-0.6.9 lib/lrama/lexer/grammar_file.rb
lrama-0.6.8 lib/lrama/lexer/grammar_file.rb
lrama-0.6.7 lib/lrama/lexer/grammar_file.rb
lrama-0.6.6 lib/lrama/lexer/grammar_file.rb