Class: Clarification::Objectifier

Inherits:
Object
  • Object
show all
Defined in:
lib/clarification/objectifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Objectifier

Returns a new instance of Objectifier.



6
7
8
9
10
11
12
# File 'lib/clarification/objectifier.rb', line 6

def initialize(response)
  @response_json = JSON.parse(response)
  @status = OpenStruct.new(@response_json["status"])
  @concepts = []

  build_concept_objects
end

Instance Attribute Details

#conceptsObject (readonly)

Returns the value of attribute concepts.



4
5
6
# File 'lib/clarification/objectifier.rb', line 4

def concepts
  @concepts
end

#response_jsonObject (readonly)

Returns the value of attribute response_json.



4
5
6
# File 'lib/clarification/objectifier.rb', line 4

def response_json
  @response_json
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/clarification/objectifier.rb', line 4

def status
  @status
end

Instance Method Details

#build_concept_objectsObject



14
15
16
17
18
# File 'lib/clarification/objectifier.rb', line 14

def build_concept_objects
  @response_json["outputs"][0]["data"]["concepts"].each do |concept|
    @concepts << OpenStruct.new(concept)
  end
end