class DatarocketsStyle::Cop::Style::NestedInterpolation
This cop checks nested interpolations
@example
# bad “Hello, #{user.blank? ? 'guest' : ”dear #{user.name}“}”
# good user_name = user.blank? ? 'guest' : “dear #{user.name}” “Hello, #{user_name}”
Constants
- MSG
Public Instance Methods
on_interpolation(node)
click to toggle source
# File lib/datarockets_style/cop/style/nested_interpolation.rb, line 19 def on_interpolation(node) node.each_descendant(:dstr) do |descendant_node| detect_double_interpolation(descendant_node) end end
Private Instance Methods
detect_double_interpolation(node)
click to toggle source
# File lib/datarockets_style/cop/style/nested_interpolation.rb, line 27 def detect_double_interpolation(node) node.each_child_node(:begin) do |begin_node| add_offense(begin_node) end end