Class: YAML::Transformer::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/yaml_extensions/transform.rb

Constant Summary collapse

@@cpt =
0

Instance Method Summary collapse

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_sObject



200
201
202
# File 'lib/yaml_extensions/transform.rb', line 200

def to_s
  @name.nil? ? unique_name : "\"#{@name}\""
end

#unique_nameObject



196
197
198
# File 'lib/yaml_extensions/transform.rb', line 196

def unique_name
  "match#{@uid}"
end