Class: RuboCop::Cop::Yoshiki::Style::NestedHtmlOptionKeys::Printer
- Inherits:
-
Object
- Object
- RuboCop::Cop::Yoshiki::Style::NestedHtmlOptionKeys::Printer
- Defined in:
- lib/rubocop/cop/yoshiki/style/nested_html_option_keys/rewriter.rb
Overview
Format nested entries back into a hash literal.
Instance Method Summary collapse
Instance Method Details
#render(node, entries) ⇒ Object
238 239 240 241 242 243 244 |
# File 'lib/rubocop/cop/yoshiki/style/nested_html_option_keys/rewriter.rb', line 238 def render node, entries parts = entries.map { render_entry(it) } return multiline(node, parts) if node.multiline? return "{ #{ parts.join(', ') } }" if node.braces? parts.join(', ') end |
#render_entry(entry) ⇒ Object
246 247 248 249 250 251 252 |
# File 'lib/rubocop/cop/yoshiki/style/nested_html_option_keys/rewriter.rb', line 246 def render_entry entry case entry[:kind] when :raw then entry[:source] when :leaf then leaf_source(entry) else "#{ entry[:name] }: #{ render_branch(entry) }" end end |