Module: RuboCop::Cop::NodeFormattingHelper
- Included in:
- YiffSpace::BelongsToUser, YiffSpace::BelongsToUserInvalidIp, YiffSpace::BelongsToUserMissingIp, YiffSpace::ResolvableUser, YiffSpace::UserToId
- Defined in:
- lib/rubocop/cop/mixin/node_formatting_helper.rb
Constant Summary collapse
- BASIC =
rubocop:disable Lint/BooleanSymbol – No, no I do not want literal values for the keys
{ true: true, false: false, nil: nil, }.freeze
Instance Method Summary collapse
-
#format_node(node, default = nil) ⇒ Object
rubocop:enable Lint/BooleanSymbol.
Instance Method Details
#format_node(node, default = nil) ⇒ Object
rubocop:enable Lint/BooleanSymbol
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/cop/mixin/node_formatting_helper.rb', line 14 def format_node(node, default = nil) return default if node.nil? return node.map { |n| format_node(n) } if node.is_a?(Array) case node.type when :sym, :str, :dstr, :int, :dsym, :float, :rational format_literal(node) when *BASIC.keys get_basic(node) when :pair format_pair(node) when :hash format_hash(node) when :lvar, :block node.source when :array format_array(node) else raise(StandardError, "Don't know how to format #{node.type}") end end |