Class: MajortomConnector::Connector
- Inherits:
-
Object
- Object
- MajortomConnector::Connector
- Defined in:
- lib/majortom_connector/connector.rb
Instance Method Summary collapse
- #clear_cache ⇒ Object
- #config ⇒ Object
- #established? ⇒ Boolean
- #find_topic_map_id_by_base_iri(base_iri) ⇒ Object
-
#initialize(id_or_base_iri) ⇒ Connector
constructor
A new instance of Connector.
- #list_maps ⇒ Object
- #ready? ⇒ Boolean
- #request ⇒ Object
- #search(query = "") ⇒ Object
- #sparql(query) ⇒ Object
- #tmql(query) ⇒ Object
- #to_ctm ⇒ Object
- #to_xtm ⇒ Object
- #topic_map_id ⇒ Object
- #topics ⇒ Object
Constructor Details
#initialize(id_or_base_iri) ⇒ Connector
Returns a new instance of Connector.
4 5 6 7 |
# File 'lib/majortom_connector/connector.rb', line 4 def initialize(id_or_base_iri) return unless ready? config.map_id = id_or_base_iri.match(/^http/) ? find_topic_map_id_by_base_iri(id_or_base_iri) : id_or_base_iri end |
Instance Method Details
#clear_cache ⇒ Object
45 46 47 |
# File 'lib/majortom_connector/connector.rb', line 45 def clear_cache request.run('clearcache') if ready? end |
#config ⇒ Object
61 62 63 |
# File 'lib/majortom_connector/connector.rb', line 61 def config @config ||= Config.new end |
#established? ⇒ Boolean
53 54 55 |
# File 'lib/majortom_connector/connector.rb', line 53 def established? ready? && request.run('connectiontest').code == "0" end |
#find_topic_map_id_by_base_iri(base_iri) ⇒ Object
17 18 19 |
# File 'lib/majortom_connector/connector.rb', line 17 def find_topic_map_id_by_base_iri(base_iri) request.run('resolvetm', base_iri).data if ready? end |
#list_maps ⇒ Object
13 14 15 |
# File 'lib/majortom_connector/connector.rb', line 13 def list_maps request.run('topicmaps') if ready? end |
#ready? ⇒ Boolean
49 50 51 |
# File 'lib/majortom_connector/connector.rb', line 49 def ready? config.ready? end |
#request ⇒ Object
57 58 59 |
# File 'lib/majortom_connector/connector.rb', line 57 def request @request ||= Request.new(config) end |
#search(query = "") ⇒ Object
33 34 35 |
# File 'lib/majortom_connector/connector.rb', line 33 def search(query = "") request.run('beru', query) if ready? end |
#sparql(query) ⇒ Object
29 30 31 |
# File 'lib/majortom_connector/connector.rb', line 29 def sparql(query) request.run('sparql', query) if ready? end |
#tmql(query) ⇒ Object
25 26 27 |
# File 'lib/majortom_connector/connector.rb', line 25 def tmql(query) request.run('tmql', query) if ready? end |
#to_ctm ⇒ Object
41 42 43 |
# File 'lib/majortom_connector/connector.rb', line 41 def to_ctm request.run('ctm') if ready? end |
#to_xtm ⇒ Object
37 38 39 |
# File 'lib/majortom_connector/connector.rb', line 37 def to_xtm request.run('xtm') if ready? end |
#topic_map_id ⇒ Object
9 10 11 |
# File 'lib/majortom_connector/connector.rb', line 9 def topic_map_id config.map_id ||= "" end |
#topics ⇒ Object
21 22 23 |
# File 'lib/majortom_connector/connector.rb', line 21 def topics request.run('topics') if ready? end |