Class: Lrama::Lexer::GrammarFile

Inherits:
Object
  • Object
show all
Defined in:
lib/lrama/lexer/grammar_file.rb

Defined Under Namespace

Classes: Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, text) ⇒ GrammarFile

Returns a new instance of GrammarFile.



18
19
20
21
# File 'lib/lrama/lexer/grammar_file.rb', line 18

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

Instance Attribute Details

#pathObject (readonly)

: String



14
15
16
# File 'lib/lrama/lexer/grammar_file.rb', line 14

def path
  @path
end

#textObject (readonly)

: String



15
16
17
# File 'lib/lrama/lexer/grammar_file.rb', line 15

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
# File 'lib/lrama/lexer/grammar_file.rb', line 29

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

#inspectObject



24
25
26
# File 'lib/lrama/lexer/grammar_file.rb', line 24

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

#linesObject



35
36
37
# File 'lib/lrama/lexer/grammar_file.rb', line 35

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