class Picatrix::LinkRelationIndex

Attributes

as_hash[RW]

Public Class Methods

new(edges) click to toggle source
# File lib/picatrix/link_relation_index.rb, line 4
def initialize(edges)
  @as_hash = {
    link_relations: edges.flat_map do |e|
      source = e.first.at(0)
      link_relation = e.first.at(1)[:link_relation]

      {
        link_relation.to_sym => "#{source} -(#{e.first.at(1)[:method].upcase})-> #{e.first.at(1)[:target]}"
      }
    end.inject(Hash.new([])) do |h, a|
      h[a.keys.first] += [a.values].flatten; h
    end
  }

  @controls = {
    "@controls": {
      up: up_href,
      self: self_href
    }
  }
end

Public Instance Methods

masoned() click to toggle source
# File lib/picatrix/link_relation_index.rb, line 25
def masoned
  @controls.merge!(@as_hash)
end

Private Instance Methods

self_href() click to toggle source
# File lib/picatrix/link_relation_index.rb, line 32
def self_href
  "http://localhost:9292/rels"
end
up_href() click to toggle source
# File lib/picatrix/link_relation_index.rb, line 29
def up_href
  "http://localhost:9292/"
end