Class: Clarinet::Concepts
- Inherits:
-
Object
- Object
- Clarinet::Concepts
- Extended by:
- Forwardable
- Defined in:
- lib/clarinet/concepts.rb
Instance Method Summary collapse
- #create(concepts) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(app, raw_data = []) ⇒ Concepts
constructor
A new instance of Concepts.
- #list(options = { page: 1, per_page: 20 }) ⇒ Object
- #search(name, language = nil) ⇒ Object
Constructor Details
#initialize(app, raw_data = []) ⇒ Concepts
Returns a new instance of Concepts.
9 10 11 12 13 14 15 16 |
# File 'lib/clarinet/concepts.rb', line 9 def initialize(app, raw_data = []) @app = app @raw_data = raw_data @concepts = raw_data.map do |concept_data| Clarinet::Concept.new concept_data end end |
Instance Method Details
#create(concepts) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/clarinet/concepts.rb', line 18 def create(concepts) concepts = [concepts] unless concepts.is_a? Array concepts = concepts.map { |concept| format_concept(concept) } data = @app.client.concepts.create concepts Clarinet::Concepts.new @app, data[:concepts] end |
#get(id) ⇒ Object
31 32 33 34 |
# File 'lib/clarinet/concepts.rb', line 31 def get(id) data = @app.client.concept id Clarinet::Concept.new data[:concept] end |
#list(options = { page: 1, per_page: 20 }) ⇒ Object
26 27 28 29 |
# File 'lib/clarinet/concepts.rb', line 26 def list( = { page: 1, per_page: 20 }) data = @app.client.concepts Clarinet::Concepts.new @app, data[:concepts] end |
#search(name, language = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/clarinet/concepts.rb', line 36 def search(name, language = nil) query = { name: name, language: language } data = @app.client.concepts_search query Clarinet::Concepts.new @app, data[:concepts] end |