Class: YAML::Transformer::Match
- Defined in:
- lib/yaml_extensions/transform.rb
Constant Summary collapse
- @@cpt =
0
Instance Method Summary collapse
- #call(key, value) ⇒ Object (also: #[])
- #dottify(stream) ⇒ Object
-
#initialize(name = nil, &block) ⇒ Match
constructor
A new instance of Match.
- #to_s ⇒ Object
- #unique_name ⇒ Object
Constructor Details
#initialize(name = nil, &block) ⇒ Match
Returns a new instance of Match.
178 179 180 181 182 183 |
# File 'lib/yaml_extensions/transform.rb', line 178 def initialize ( name=nil, &block ) @block = block @name = name @uid = @@cpt @@cpt += 1 end |
Instance Method Details
#call(key, value) ⇒ Object Also known as: []
190 191 192 |
# File 'lib/yaml_extensions/transform.rb', line 190 def call ( key, value ) @block[key, value] end |
#dottify(stream) ⇒ Object
186 187 188 |
# File 'lib/yaml_extensions/transform.rb', line 186 def dottify ( stream ) stream << "match#{@uid} [shape=circle, color=green, label=#{self}]\n" end |
#to_s ⇒ Object
200 201 202 |
# File 'lib/yaml_extensions/transform.rb', line 200 def to_s @name.nil? ? unique_name : "\"#{@name}\"" end |
#unique_name ⇒ Object
196 197 198 |
# File 'lib/yaml_extensions/transform.rb', line 196 def unique_name "match#{@uid}" end |