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.



380
381
382
# File 'lib/graph.rb', line 380

def initialize graph
  super graph, []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



379
380
381
# File 'lib/graph.rb', line 379

def attributes
  @attributes
end

#graphObject

Returns the value of attribute graph

Returns:

  • (Object)

    the current value of graph



379
380
381
# File 'lib/graph.rb', line 379

def graph
  @graph
end

Instance Method Details

#attributes?Boolean

Does this thing have attributes?

Returns:

  • (Boolean)


401
402
403
# File 'lib/graph.rb', line 401

def attributes?
  not self.attributes.empty?
end

#initialize_copy(other) ⇒ Object

:nodoc:



384
385
386
387
# File 'lib/graph.rb', line 384

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

#label(name) ⇒ Object

Shortcut method to set the label attribute.



392
393
394
395
396
# File 'lib/graph.rb', line 392

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