Class: Urbit::Link

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chain:, path:, data:) ⇒ Link

Returns a new instance of Link.



7
8
9
10
11
12
13
# File 'lib/urbit/link.rb', line 7

def initialize(chain:, path:, data:)
  @chain = chain
  @graph = nil
  @group = nil
  @path  = path
  @data  = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/urbit/link.rb', line 5

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/urbit/link.rb', line 5

def path
  @path
end

Instance Method Details

#<=>(another) ⇒ Object



19
20
21
# File 'lib/urbit/link.rb', line 19

def <=>(another)
  self.path <=> another.path
end

#==(another) ⇒ Object



15
16
17
# File 'lib/urbit/link.rb', line 15

def ==(another)
  another.path == self.path
end

#eql?(another) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/urbit/link.rb', line 23

def eql?(another)
  another.path == self.path
end

#graphObject



27
28
29
30
31
32
# File 'lib/urbit/link.rb', line 27

def graph
  if @graph.nil?
    @graph = self.ship.graph(resource: self.graph_resource)
  end
  @graph
end


34
35
36
# File 'lib/urbit/link.rb', line 34

def graph_links
  @chain.find_graph_links_for_group(path: self.group_path)
end

#graph_resourceObject



38
39
40
# File 'lib/urbit/link.rb', line 38

def graph_resource
  @data['resource'].sub('/ship/', '')
end

#groupObject



42
43
44
45
46
47
# File 'lib/urbit/link.rb', line 42

def group
  if @group.nil?
    @group = self.ship.groups[path: self.group_path]
  end
  @group
end

#group_pathObject



49
50
51
# File 'lib/urbit/link.rb', line 49

def group_path
  @data['group'].sub('/ship/', '')
end

#metadataObject



53
54
55
# File 'lib/urbit/link.rb', line 53

def 
  @data['metadata']
end

#shipObject



57
58
59
# File 'lib/urbit/link.rb', line 57

def ship
  @chain.ship
end

#to_listObject



61
62
63
# File 'lib/urbit/link.rb', line 61

def to_list
  @path
end

#typeObject



65
66
67
# File 'lib/urbit/link.rb', line 65

def type
  @data['app-name']
end