Class: GoogleKnowledgeGraph::Entity
- Inherits:
-
Object
- Object
- GoogleKnowledgeGraph::Entity
- Defined in:
- lib/google_knowledge_graph/entity.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #description ⇒ Object
- #description_text ⇒ Object
- #description_url ⇒ Object
- #detailed_description ⇒ Object
- #id ⇒ Object
- #id_without_prefix ⇒ Object
- #image ⇒ Object
- #image_url ⇒ Object
-
#initialize(data) ⇒ Entity
constructor
A new instance of Entity.
- #name ⇒ Object
- #types ⇒ Object
- #url ⇒ Object
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
#data ⇒ Object (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
#description ⇒ Object
37 38 39 |
# File 'lib/google_knowledge_graph/entity.rb', line 37 def description @data['description'] end |
#description_text ⇒ Object
45 46 47 |
# File 'lib/google_knowledge_graph/entity.rb', line 45 def description_text detailed_description&.dig 'articleBody' end |
#description_url ⇒ Object
49 50 51 |
# File 'lib/google_knowledge_graph/entity.rb', line 49 def description_url detailed_description&.dig 'url' end |
#detailed_description ⇒ Object
41 42 43 |
# File 'lib/google_knowledge_graph/entity.rb', line 41 def detailed_description @data['detailedDescription'] end |
#id ⇒ Object
9 10 11 |
# File 'lib/google_knowledge_graph/entity.rb', line 9 def id @data['@id'] end |
#id_without_prefix ⇒ Object
13 14 15 |
# File 'lib/google_knowledge_graph/entity.rb', line 13 def id_without_prefix id.delete_prefix 'kg:' end |
#image ⇒ Object
29 30 31 |
# File 'lib/google_knowledge_graph/entity.rb', line 29 def image @data['image'] end |
#image_url ⇒ Object
33 34 35 |
# File 'lib/google_knowledge_graph/entity.rb', line 33 def image_url @data.dig 'image', 'contentUrl' end |
#name ⇒ Object
21 22 23 |
# File 'lib/google_knowledge_graph/entity.rb', line 21 def name @data['name'] end |
#types ⇒ Object
17 18 19 |
# File 'lib/google_knowledge_graph/entity.rb', line 17 def types @data['@type'] end |
#url ⇒ Object
25 26 27 |
# File 'lib/google_knowledge_graph/entity.rb', line 25 def url @data['url'] end |