Class: Oppen::Token::Break

Inherits:
Oppen::Token show all
Defined in:
lib/oppen/token.rb

Overview

Break Token.

Direct Known Subclasses

LineBreak

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str = ' ', line_continuation: '', offset: 0, width: str.length) ⇒ Break

Returns a new instance of Break.

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
# File 'lib/oppen/token.rb', line 52

def initialize(str = ' ', line_continuation: '', offset: 0, width: str.length)
  raise ArgumentError, 'line_continuation cannot be nil' if line_continuation.nil?

  @line_continuation = line_continuation
  @offset = offset
  @str = str
  @width = width
  super()
end

Instance Attribute Details

#line_continuationString (readonly)

Returns If a new line is needed, display this string before the new line.

Returns:

  • (String)

    If a new line is needed, display this string before the new line.

See Also:



44
45
46
# File 'lib/oppen/token.rb', line 44

def line_continuation
  @line_continuation
end

#offsetInteger (readonly)

Returns Indentation.

Returns:

  • (Integer)

    Indentation.



46
47
48
# File 'lib/oppen/token.rb', line 46

def offset
  @offset
end

#strString (readonly)

Returns Break strings.

Returns:



48
49
50
# File 'lib/oppen/token.rb', line 48

def str
  @str
end

#widthInteger (readonly)

Returns:

  • (Integer)


50
51
52
# File 'lib/oppen/token.rb', line 50

def width
  @width
end

Instance Method Details

#to_sString

Convert token to String.

Returns:



65
# File 'lib/oppen/token.rb', line 65

def to_s = str