Class: SCSSLint::Linter::SpaceAroundOperator::OperationSources
- Inherits:
-
Object
- Object
- SCSSLint::Linter::SpaceAroundOperator::OperationSources
- Defined in:
- lib/scss_lint/linter/space_around_operator.rb
Overview
A helper class for storing and adjusting the sources of the different components of an Operation node.
Instance Attribute Summary collapse
-
#operator_source ⇒ Object
readonly
Returns the value of attribute operator_source.
Instance Method Summary collapse
- #adjust_for_interpolation ⇒ Object
- #adjust_sources ⇒ Object
-
#initialize(node, linter) ⇒ OperationSources
constructor
A new instance of OperationSources.
- #no_space_msg(operator) ⇒ Object
- #space_msg(operator) ⇒ Object
Constructor Details
#initialize(node, linter) ⇒ OperationSources
Returns a new instance of OperationSources.
78 79 80 81 82 83 84 |
# File 'lib/scss_lint/linter/space_around_operator.rb', line 78 def initialize(node, linter) @node = node @linter = linter @source = normalize_source(@linter.source_fm_range(@node.source_range)) @left_range = @node.operand1.source_range @right_range = @node.operand2.source_range end |
Instance Attribute Details
#operator_source ⇒ Object (readonly)
Returns the value of attribute operator_source.
76 77 78 |
# File 'lib/scss_lint/linter/space_around_operator.rb', line 76 def operator_source @operator_source end |
Instance Method Details
#adjust_for_interpolation ⇒ Object
96 97 98 99 100 |
# File 'lib/scss_lint/linter/space_around_operator.rb', line 96 def adjust_for_interpolation @source = normalize_source(@linter.source_fm_range((@node.source_range))) @left_range = (@node.operand1.source_range) @right_range = (@node.operand2.source_range) end |
#adjust_sources ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/scss_lint/linter/space_around_operator.rb', line 86 def adjust_sources # We need to #chop at the end because an operation's operand1 _always_ # includes one character past the actual operand (which is either a # whitespace character, or the first character of the operation). @left_source = normalize_source(@linter.source_fm_range(@left_range)) @right_source = normalize_source(@linter.source_fm_range(@right_range)) @operator_source = calculate_operator_source adjust_left_boundary end |
#no_space_msg(operator) ⇒ Object
106 107 108 |
# File 'lib/scss_lint/linter/space_around_operator.rb', line 106 def no_space_msg(operator) NO_SPACE_MSG % [@source, @left_source, operator, @right_source] end |
#space_msg(operator) ⇒ Object
102 103 104 |
# File 'lib/scss_lint/linter/space_around_operator.rb', line 102 def space_msg(operator) SPACE_MSG % [@source, @left_source, operator, @right_source] end |