Module: Psychgus::Stylables::StyleStylable
- Includes:
- Psychgus::Styler
- Included in:
- MapFlowStylable, SeqFlowStylable
- Defined in:
- lib/psychgus/stylables.rb
Overview
A helper mixin for Stylables that change a node’s style.
There is no max level, because a parent’s style will override all of its children.
Constant Summary
Constants included from Psychgus::Styler
Instance Attribute Summary collapse
-
#min_level ⇒ Integer
The minimum level (inclusive) to style.
-
#new_style ⇒ Integer
The new style to set the nodes to.
Instance Method Summary collapse
-
#change_style(sniffer, node) ⇒ Object
Change the style of
node
to #new_style if it is >= #min_level. -
#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.
Methods included from Psychgus::Styler
#style, #style_alias, #style_document, #style_mapping, #style_scalar, #style_sequence, #style_stream
Instance Attribute Details
#min_level ⇒ Integer
Returns the minimum level (inclusive) to style.
33 34 35 |
# File 'lib/psychgus/stylables.rb', line 33 def min_level @min_level end |
#new_style ⇒ Integer
Returns the new style to set the nodes to.
34 35 36 |
# File 'lib/psychgus/stylables.rb', line 34 def new_style @new_style end |
Instance Method Details
#change_style(sniffer, node) ⇒ Object
Change the style of node
to #new_style if it is >= #min_level.
47 48 49 50 51 |
# File 'lib/psychgus/stylables.rb', line 47 def change_style(sniffer,node) return unless node.respond_to?(:style=) node.style = @new_style if sniffer.level >= @min_level end |
#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.
41 42 43 44 |
# File 'lib/psychgus/stylables.rb', line 41 def initialize(min_level=0,new_style: nil,**kargs) @min_level = min_level @new_style = new_style end |