Class: Graph::Thingy

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

Direct Known Subclasses

Edge, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ Thingy

Returns a new instance of Thingy.



433
434
435
# File 'lib/graph.rb', line 433

def initialize graph
  super graph, []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



432
433
434
# File 'lib/graph.rb', line 432

def attributes
  @attributes
end

#graphObject

Returns the value of attribute graph

Returns:

  • (Object)

    the current value of graph



432
433
434
# File 'lib/graph.rb', line 432

def graph
  @graph
end

Instance Method Details

#attributes?Boolean

Does this thing have attributes?

Returns:

  • (Boolean)


454
455
456
# File 'lib/graph.rb', line 454

def attributes?
  not self.attributes.empty?
end

#initialize_copy(other) ⇒ Object

:nodoc:



437
438
439
440
# File 'lib/graph.rb', line 437

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

#label(name) ⇒ Object

Shortcut method to set the label attribute.



445
446
447
448
449
# File 'lib/graph.rb', line 445

def label name
  attributes.reject! { |s| s =~ /^label =/ }
  attributes << "label = \"#{name.gsub(/\n/, '\n')}\""
  self
end