Class: Yamlint::Models::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/yamlint/models/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, start_line:, start_column:, value: nil, end_line: nil, end_column: nil) ⇒ Token

Returns a new instance of Token.



8
9
10
11
12
13
14
15
# File 'lib/yamlint/models/token.rb', line 8

def initialize(type:, start_line:, start_column:, value: nil, end_line: nil, end_column: nil)
  @type = type
  @value = value
  @start_line = start_line
  @start_column = start_column
  @end_line = end_line || start_line
  @end_column = end_column || start_column
end

Instance Attribute Details

#end_columnObject (readonly)

Returns the value of attribute end_column.



6
7
8
# File 'lib/yamlint/models/token.rb', line 6

def end_column
  @end_column
end

#end_lineObject (readonly)

Returns the value of attribute end_line.



6
7
8
# File 'lib/yamlint/models/token.rb', line 6

def end_line
  @end_line
end

#start_columnObject (readonly)

Returns the value of attribute start_column.



6
7
8
# File 'lib/yamlint/models/token.rb', line 6

def start_column
  @start_column
end

#start_lineObject (readonly)

Returns the value of attribute start_line.



6
7
8
# File 'lib/yamlint/models/token.rb', line 6

def start_line
  @start_line
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/yamlint/models/token.rb', line 6

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/yamlint/models/token.rb', line 6

def value
  @value
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/yamlint/models/token.rb', line 17

def to_s
  "#{type}(#{start_line}:#{start_column})"
end