Module: Psychgus::Styler
- Included in:
- Psychgus::Stylables::CapStylable, Psychgus::Stylables::HierarchyStylable, Psychgus::Stylables::NoSymStylable, Psychgus::Stylables::NoTagStylable, Psychgus::Stylables::StyleStylable, Empty
- Defined in:
- lib/psychgus/styler.rb,
lib/psychgus/styler.rb
Overview
Mix in (include) this module to make a class/module/etc. a styler for YAML.
Although it’s unnecessary (because of Duck Typing), it’s the recommended practice in case a new method is added in the future, and also so you don’t have to define methods that you don’t use.
You can either use this as is (see example) or inside of a class (see Blueberry).
Defined Under Namespace
Classes: Empty
Constant Summary collapse
- EMPTY =
Empty.new.freeze
Instance Method Summary collapse
-
#style(sniffer, node) ⇒ Object
Style a node of any type.
-
#style_alias(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Alias, to avoid if statements.
-
#style_document(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Document, to avoid if statements.
-
#style_mapping(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Mapping, to avoid if statements.
-
#style_scalar(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Scalar, to avoid if statements.
-
#style_sequence(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Sequence, to avoid if statements.
-
#style_stream(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Stream, to avoid if statements.
Instance Method Details
#style(sniffer, node) ⇒ Object
Style a node of any type.
You can use Ext::NodeExt#node_of? to determine its type:
puts node.value if node.node_of?(:scalar)
71 |
# File 'lib/psychgus/styler.rb', line 71 def style(sniffer,node) end |
#style_alias(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Alias, to avoid if statements.
77 |
# File 'lib/psychgus/styler.rb', line 77 def style_alias(sniffer,node) end |
#style_document(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Document, to avoid if statements.
83 |
# File 'lib/psychgus/styler.rb', line 83 def style_document(sniffer,node) end |
#style_mapping(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Mapping, to avoid if statements.
89 |
# File 'lib/psychgus/styler.rb', line 89 def style_mapping(sniffer,node) end |
#style_scalar(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Scalar, to avoid if statements.
95 |
# File 'lib/psychgus/styler.rb', line 95 def style_scalar(sniffer,node) end |
#style_sequence(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Sequence, to avoid if statements.
101 |
# File 'lib/psychgus/styler.rb', line 101 def style_sequence(sniffer,node) end |
#style_stream(sniffer, node) ⇒ Object
Style a node guaranteed to be of type Psych::Nodes::Stream, to avoid if statements.
107 |
# File 'lib/psychgus/styler.rb', line 107 def style_stream(sniffer,node) end |