Class: GoogleKnowledgeGraph::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/google_knowledge_graph/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Entity

Returns a new instance of Entity.



5
6
7
# File 'lib/google_knowledge_graph/entity.rb', line 5

def initialize data
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/google_knowledge_graph/entity.rb', line 3

def data
  @data
end

Instance Method Details

#descriptionObject



37
38
39
# File 'lib/google_knowledge_graph/entity.rb', line 37

def description
  @data['description']
end

#description_textObject



45
46
47
# File 'lib/google_knowledge_graph/entity.rb', line 45

def description_text
  detailed_description&.dig 'articleBody'
end

#description_urlObject



49
50
51
# File 'lib/google_knowledge_graph/entity.rb', line 49

def description_url
  detailed_description&.dig 'url'
end

#detailed_descriptionObject



41
42
43
# File 'lib/google_knowledge_graph/entity.rb', line 41

def detailed_description
  @data['detailedDescription']
end

#idObject



9
10
11
# File 'lib/google_knowledge_graph/entity.rb', line 9

def id
  @data['@id']
end

#id_without_prefixObject



13
14
15
# File 'lib/google_knowledge_graph/entity.rb', line 13

def id_without_prefix
  id.delete_prefix 'kg:'
end

#imageObject



29
30
31
# File 'lib/google_knowledge_graph/entity.rb', line 29

def image
  @data['image']
end

#image_urlObject



33
34
35
# File 'lib/google_knowledge_graph/entity.rb', line 33

def image_url
  @data.dig 'image', 'contentUrl'
end

#nameObject



21
22
23
# File 'lib/google_knowledge_graph/entity.rb', line 21

def name
  @data['name']
end

#typesObject



17
18
19
# File 'lib/google_knowledge_graph/entity.rb', line 17

def types
  @data['@type']
end

#urlObject



25
26
27
# File 'lib/google_knowledge_graph/entity.rb', line 25

def url
  @data['url']
end