Class: GV::Component

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

Overview

Common super-class for edges, nodes and graphs

Direct Known Subclasses

BaseGraph, Edge, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#graphGraph, SubGraph (readonly)

Returns the graph this component belongs to.

Returns:



70
71
72
# File 'lib/gv.rb', line 70

def graph
  @graph
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



87
88
89
# File 'lib/gv.rb', line 87

def ==(other)
  other.is_a?(Component) && ptr == other.ptr
end

#[](attr) ⇒ Object

Retrieves the value of an attribute

Parameters:

  • attr (Symbol, String)

    attribute name

Returns:

  • (Object)

    the attribute value

See Also:



110
111
112
# File 'lib/gv.rb', line 110

def [](attr)
  Libcgraph.agget(ptr, attr.to_s)
end

#[]=(attr, value) ⇒ Object

Sets an attribute

Parameters:

  • attr (Symbol, String)

    attribute name

  • value (Object)

    attribute value

See Also:



102
103
104
# File 'lib/gv.rb', line 102

def []=(attr, value)
  Libcgraph.agsafeset(ptr, attr.to_s, value.to_s, '')
end

#hashObject



83
84
85
# File 'lib/gv.rb', line 83

def hash
  ptr.hash
end

#html(string) ⇒ Object

Creates an HTML label

Parameters:

  • string (String)

    the HTML to parse

Returns:

  • (Object)

    a HTML label



75
76
77
78
79
80
81
# File 'lib/gv.rb', line 75

def html(string)
  ptr = Libcgraph.agstrdup_html(graph.ptr, string)
  string = ptr.read_string
  Libcgraph.agstrfree graph.ptr, ptr

  string
end

#nameString

Returns the component’s name.

Returns:

  • (String)

    the component’s name



94
95
96
# File 'lib/gv.rb', line 94

def name
  Libcgraph.agnameof ptr
end