Class: Dag::Standard::EndPoint

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

Overview

Encapsulates the necessary information about a graph node

Direct Known Subclasses

Sink, Source

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ EndPoint

Initializes an endpoint based on an Id



27
28
29
# File 'lib/dag/standard.rb', line 27

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



31
32
33
# File 'lib/dag/standard.rb', line 31

def id
  @id
end

Class Method Details

.from(obj) ⇒ Object

Factory Construction method that creates an endpoint from a model if necessary



21
22
23
24
# File 'lib/dag/standard.rb', line 21

def self.from(obj)
  return obj if obj.kind_of?(EndPoint)
  self.from_resource(obj)
end

.from_resource(resource) ⇒ Object

Factory Construction method that creates an endpoint from a model



16
17
18
# File 'lib/dag/standard.rb', line 16

def self.from_resource(resource)
  self.new(resource.id)
end

Instance Method Details

#matches?(other) ⇒ Boolean

Does an endpoint match another endpoint or model instance

Returns:

  • (Boolean)


11
12
13
# File 'lib/dag/standard.rb', line 11

def matches?(other)
  self.id == other.id
end