Module: Psychgus::Stylables::NoTagStylable

Includes:
Psychgus::Styler
Included in:
Psychgus::Stylers::NoTagStyler
Defined in:
lib/psychgus/stylables.rb

Overview

A Tag remover for classes.

Examples:

require 'psychgus'

class Eggs
  def initialize
    @styles = ['Fried', 'Scrambled', ['BBQ', 'Ketchup']]
    @colors = ['Brown', 'White', ['Blue', 'Green']]
  end
end

class EggCarton
  include Psychgus::Blueberry

  def initialize
    @eggs = Eggs.new
  end

  def psychgus_stylers(sniffer)
    Psychgus::FlowStyler.new(4)
  end
end

puts EggCarton.new.to_yaml

# Output:
# --- !ruby/object:EggCarton
# eggs: !ruby/object:Eggs
#   styles: [Fried, Scrambled, [BBQ, Ketchup]]
#   colors: [Brown, White, [Blue, Green]]

puts EggCarton.new.to_yaml(stylers: Psychgus::NoTagStyler.new)

# Output:
# ---
# eggs:
#   styles: [Fried, Scrambled, [BBQ, Ketchup]]
#   colors: [Brown, White, [Blue, Green]]

See Also:

Since:

  • 1.2.0

Constant Summary

Constants included from Psychgus::Styler

Psychgus::Styler::EMPTY

Instance Method Summary collapse

Methods included from Psychgus::Styler

#style_alias, #style_document, #style_mapping, #style_scalar, #style_sequence, #style_stream

Instance Method Details

#style(sniffer, node) ⇒ Object

If node.tag is settable, set it to nil.

See Also:

Since:

  • 1.2.0



242
243
244
# File 'lib/psychgus/stylables.rb', line 242

def style(sniffer,node)
  node.tag = nil if node.respond_to?(:tag=)
end