Module: Psychgus::Stylables::MapFlowStylable

Includes:
StyleStylable
Included in:
Psychgus::Stylers::FlowStyler, Psychgus::Stylers::MapFlowStyler
Defined in:
lib/psychgus/stylables.rb

Overview

A FLOW style changer for Mappings only.

Constant Summary

Constants included from Psychgus::Styler

Psychgus::Styler::EMPTY

Instance Attribute Summary

Attributes included from StyleStylable

#min_level, #new_style

Instance Method Summary collapse

Methods included from StyleStylable

#change_style

Methods included from Psychgus::Styler

#style, #style_alias, #style_document, #style_scalar, #style_sequence, #style_stream

Instance Method Details

#initialize(min_level = 0, new_style: nil, **kargs) ⇒ Object

max_level is not defined because a parent's style will override all of its children.

If new_style is nil (the default), then MAPPING_FLOW will be used.

Parameters:

  • min_level (Integer) (defaults to: 0)

    the minimum level (inclusive) to style

  • new_style (Integer) (defaults to: nil)

    the new style to set the nodes to

  • kargs (Hash)

    capture extra keyword args, so no error for undefined args

Since:

  • 1.2.0



189
190
191
192
193
# File 'lib/psychgus/stylables.rb', line 189

def initialize(*)
  super
  
  @new_style = MAPPING_FLOW if @new_style.nil?()
end

#style_mapping(sniffer, node) ⇒ Object

Change the style of a Mapping to FLOW (or to the value of StyleStylable#new_style) if it is >= StyleStylable#min_level.



200
201
202
# File 'lib/psychgus/stylables.rb', line 200

def style_mapping(sniffer,node)
  change_style(sniffer,node)
end