Class: Wikidata::CommandLine
- Inherits:
-
Thor
- Object
- Thor
- Wikidata::CommandLine
- Defined in:
- lib/wikidata/command_line.rb
Instance Method Summary collapse
- #find(article_name) ⇒ Object
- #get(article_id) ⇒ Object
- #traverse(article_name, relation_name) ⇒ Object
Instance Method Details
#find(article_name) ⇒ Object
11 12 13 14 |
# File 'lib/wikidata/command_line.rb', line 11 def find(article_name) display_item Wikidata::Item.find_by_title(article_name) end |
#get(article_id) ⇒ Object
19 20 21 22 |
# File 'lib/wikidata/command_line.rb', line 19 def get(article_id) display_item Wikidata::Item.find_by_id(article_id) end |
#traverse(article_name, relation_name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wikidata/command_line.rb', line 26 def traverse(article_name, relation_name) item = Wikidata::Item.find_by_title(article_name) if item puts "#{item.label.green} (#{item.id})" while true if collection = item.entities_for_property_id(relation_name) if item = collection.first puts "#{item.label.green} (#{item.id})" else break end end end end end |