Class: FixtureFox::TokenizedLine

Inherits:
Object
  • Object
show all
Defined in:
lib/fixture_fox/line.rb

Direct Known Subclasses

DirectiveLine, Line

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, lineno, initial_indent, indent, line) ⇒ TokenizedLine

Returns a new instance of TokenizedLine.



9
10
11
12
# File 'lib/fixture_fox/line.rb', line 9

def initialize(file, lineno, initial_indent, indent, line)
  @file, @line, @lineno, @initial_indent, @indent = file, line.dup, lineno, initial_indent, indent
  @pos = 1 + @indent # Used to keep track of position for the make_* methods
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/fixture_fox/line.rb', line 3

def file
  @file
end

#indentObject (readonly)

Returns the value of attribute indent.



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

def indent
  @indent
end

#initial_indentObject (readonly)

Returns the value of attribute initial_indent.



6
7
8
# File 'lib/fixture_fox/line.rb', line 6

def initial_indent
  @initial_indent
end

#lineObject (readonly)

Returns the value of attribute line.



4
5
6
# File 'lib/fixture_fox/line.rb', line 4

def line
  @line
end

#linenoObject (readonly)

Returns the value of attribute lineno.



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

def lineno
  @lineno
end

Instance Method Details

#error(msg) ⇒ Object

Raises:



14
15
16
# File 'lib/fixture_fox/line.rb', line 14

def error(msg)
  raise ParseError.new(@file, @lineno, @pos + initial_indent, msg)
end

#to_s(long: false) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/fixture_fox/line.rb', line 18

def to_s(long: false)
  if long
    "#{file}:#{lineno} "
  else
    "line #{lineno} "
  end
end