Module: Psychgus::Stylables::NoSymStylable
- Includes:
- Psychgus::Styler
- Included in:
- Psychgus::Stylers::NoSymStyler
- Defined in:
- lib/psychgus/stylables.rb
Overview
A Symbol remover for Scalars.
Constant Summary
Constants included from Psychgus::Styler
Instance Attribute Summary collapse
-
#cap ⇒ true, false
(also: #cap?)
Whether to capitalize the symbol.
Instance Method Summary collapse
- #initialize(cap: true, **kargs) ⇒ Object
-
#style_scalar(sniffer, node) ⇒ Object
If
node.value
is a symbol, change it into a string and capitalize it.
Methods included from Psychgus::Styler
#style, #style_alias, #style_document, #style_mapping, #style_sequence, #style_stream
Instance Attribute Details
#cap ⇒ true, false Also known as: cap?
Returns whether to capitalize the symbol.
196 197 198 |
# File 'lib/psychgus/stylables.rb', line 196 def cap @cap end |
Instance Method Details
#initialize(cap: true, **kargs) ⇒ Object
202 203 204 |
# File 'lib/psychgus/stylables.rb', line 202 def initialize(cap: true,**kargs) @cap = cap end |
#style_scalar(sniffer, node) ⇒ Object
If node.value
is a symbol, change it into a string and capitalize it.
209 210 211 212 213 214 215 |
# File 'lib/psychgus/stylables.rb', line 209 def style_scalar(sniffer,node) return if node.value.nil? || node.value.empty? return if node.value[0] != ':' node.value = node.value[1..-1] node.value = node.value.capitalize if @cap end |