Class: Yoda::Parsing::Query::CurrentCommentTokenQuery::InputtingLine

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/parsing/query/current_comment_token_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_sequence, column) ⇒ InputtingLine

Returns a new instance of InputtingLine.

Parameters:



76
77
78
79
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 76

def initialize(token_sequence, column)
  @token_sequence = token_sequence
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



72
73
74
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 72

def column
  @column
end

#token_sequenceObject (readonly)

Returns the value of attribute token_sequence.



69
70
71
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 69

def token_sequence
  @token_sequence
end

Instance Method Details

#at_sign?true, false

Returns:

  • (true, false)


115
116
117
118
119
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 115

def at_sign?
  current_token &&
  current_token.to_s.match?(/\A[{}.&\]\[\(\)<>]/) &&
  column == current_token.offset + current_token.size
end

#current_range(Integer, Integer)?

Returns:

  • ((Integer, Integer), nil)


87
88
89
90
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 87

def current_range
  return nil unless current_token
  [current_token.offset, current_token.offset + current_token.size]
end

#current_stateSymbol

Returns:

  • (Symbol)


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 98

def current_state
  @current_state ||= begin
    if tag && %w(@type @!sig).include?(tag.to_s) && !on_tag?
      :type_tag_type
    elsif tag && token_sequence.parameter_tokens.empty?
      :tag
    elsif in_bracket?
      :type
    elsif at_parameter_name?
      :param
    else
      :none
    end
  end
end

#current_tokenParslet::Slice?

Returns:

  • (Parslet::Slice, nil)


93
94
95
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 93

def current_token
  @current_token ||= token_sequence.all_tokens.find { |token| token.offset <= column && column <= token.offset + token.size }
end

#tagParslet::Slice?

Returns:

  • (Parslet::Slice, nil)


82
83
84
# File 'lib/yoda/parsing/query/current_comment_token_query.rb', line 82

def tag
  token_sequence.tag
end