Class: Graph::Thingy

Inherits:
Struct show all
Defined in:
lib/graph.rb

Overview

You know… THINGY!

Has a pointer back to its graph parent and attributes.

Direct Known Subclasses

Edge, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ Thingy

:nodoc:



500
501
502
# File 'lib/graph.rb', line 500

def initialize graph # :nodoc:
  super graph, []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



499
500
501
# File 'lib/graph.rb', line 499

def attributes
  @attributes
end

#graphObject

Returns the value of attribute graph

Returns:

  • (Object)

    the current value of graph



499
500
501
# File 'lib/graph.rb', line 499

def graph
  @graph
end

Instance Method Details

#attributes?Boolean

Does this thing have attributes?

Returns:

  • (Boolean)


521
522
523
# File 'lib/graph.rb', line 521

def attributes?
  not self.attributes.empty?
end

#initialize_copy(other) ⇒ Object

:nodoc:



504
505
506
507
# File 'lib/graph.rb', line 504

def initialize_copy other # :nodoc:
  super
  self.attributes = other.attributes.dup
end

#label(name) ⇒ Object

Shortcut method to set the label attribute.



512
513
514
515
516
# File 'lib/graph.rb', line 512

def label name
  attributes.reject! { |s| s =~ /^label =/ }
  attributes << "label = #{Graph.escape_label name}"
  self
end