Class: Lox::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/lox/scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Scanner

Returns a new instance of Scanner.



7
8
9
# File 'lib/lox/scanner.rb', line 7

def initialize(input)
  @input = input
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



5
6
7
# File 'lib/lox/scanner.rb', line 5

def input
  @input
end

Instance Method Details

#each_charObject



11
12
13
14
15
16
17
18
19
# File 'lib/lox/scanner.rb', line 11

def each_char
  return enum_for(:each_char) unless block_given?

  input.each_line do |line|
    line.each_char do |character|
      yield(character)
    end
  end
end