Class: Urbit::Link
- Inherits:
-
Object
- Object
- Urbit::Link
- Defined in:
- lib/urbit/link.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #<=>(another) ⇒ Object
- #==(another) ⇒ Object
- #eql?(another) ⇒ Boolean
- #graph ⇒ Object
- #graph_links ⇒ Object
- #graph_resource ⇒ Object
- #group ⇒ Object
- #group_path ⇒ Object
-
#initialize(chain:, path:, data:) ⇒ Link
constructor
A new instance of Link.
- #metadata ⇒ Object
- #ship ⇒ Object
- #to_list ⇒ Object
- #type ⇒ Object
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/urbit/link.rb', line 5 def data @data end |
#path ⇒ Object (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
23 24 25 |
# File 'lib/urbit/link.rb', line 23 def eql?(another) another.path == self.path end |
#graph ⇒ Object
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 |
#graph_links ⇒ Object
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_resource ⇒ Object
38 39 40 |
# File 'lib/urbit/link.rb', line 38 def graph_resource @data['resource'].sub('/ship/', '') end |
#group ⇒ Object
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_path ⇒ Object
49 50 51 |
# File 'lib/urbit/link.rb', line 49 def group_path @data['group'].sub('/ship/', '') end |
#metadata ⇒ Object
53 54 55 |
# File 'lib/urbit/link.rb', line 53 def @data['metadata'] end |
#ship ⇒ Object
57 58 59 |
# File 'lib/urbit/link.rb', line 57 def ship @chain.ship end |
#to_list ⇒ Object
61 62 63 |
# File 'lib/urbit/link.rb', line 61 def to_list @path end |
#type ⇒ Object
65 66 67 |
# File 'lib/urbit/link.rb', line 65 def type @data['app-name'] end |