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.
200 201 202 |
# File 'lib/psychgus/stylables.rb', line 200 def cap @cap end |
Instance Method Details
#initialize(cap: true, **kargs) ⇒ Object
206 207 208 |
# File 'lib/psychgus/stylables.rb', line 206 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.
213 214 215 216 217 218 219 |
# File 'lib/psychgus/stylables.rb', line 213 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 |