Class: Jazzy::SymbolGraph::Relationship
- Inherits:
-
Object
- Object
- Jazzy::SymbolGraph::Relationship
- Defined in:
- lib/jazzy/symbol_graph/relationship.rb
Overview
A Relationship is a tidied-up SymbolGraph JSON object
Constant Summary collapse
- KINDS =
%w[memberOf conformsTo defaultImplementationOf overrides inheritsFrom requirementOf optionalRequirementOf].freeze
Instance Attribute Summary collapse
-
#constraints ⇒ Object
array, can be empty.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#source_usr ⇒ Object
Returns the value of attribute source_usr.
-
#target_fallback ⇒ Object
can be nil.
-
#target_usr ⇒ Object
Returns the value of attribute target_usr.
Instance Method Summary collapse
- #default_implementation? ⇒ Boolean
-
#initialize(hash) ⇒ Relationship
constructor
A new instance of Relationship.
- #protocol_requirement? ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Relationship
Returns a new instance of Relationship.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 23 def initialize(hash) kind = hash[:kind] unless KINDS.include?(kind) raise "Unknown relationship kind '#{kind}'" end self.kind = kind.to_sym self.source_usr = hash[:source] self.target_usr = hash[:target] if fallback = hash[:targetFallback] # Strip the leading module name self.target_fallback = fallback.sub(/^.*?\./, '') end self.constraints = Constraint.new_list(hash[:swiftConstraints] || []) end |
Instance Attribute Details
#constraints ⇒ Object
array, can be empty
9 10 11 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 9 def constraints @constraints end |
#kind ⇒ Object
Returns the value of attribute kind.
5 6 7 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 5 def kind @kind end |
#source_usr ⇒ Object
Returns the value of attribute source_usr.
6 7 8 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 6 def source_usr @source_usr end |
#target_fallback ⇒ Object
can be nil
8 9 10 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 8 def target_fallback @target_fallback end |
#target_usr ⇒ Object
Returns the value of attribute target_usr.
7 8 9 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 7 def target_usr @target_usr end |
Instance Method Details
#default_implementation? ⇒ Boolean
19 20 21 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 19 def default_implementation? kind == :defaultImplementationOf end |
#protocol_requirement? ⇒ Boolean
15 16 17 |
# File 'lib/jazzy/symbol_graph/relationship.rb', line 15 def protocol_requirement? i[requirementOf optionalRequirementOf].include? kind end |