Class: AskAwesomely::Typeform
- Inherits:
-
Object
- Object
- AskAwesomely::Typeform
- Defined in:
- lib/ask_awesomely/typeform.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#structure ⇒ Object
readonly
Returns the value of attribute structure.
Instance Method Summary collapse
- #embed_as(type, options = {}) ⇒ Object
-
#initialize(structure) ⇒ Typeform
constructor
A new instance of Typeform.
- #private_url ⇒ Object
- #public_url ⇒ Object
- #title ⇒ Object
- #to_json ⇒ Object
- #update_with_api_response(response) ⇒ Object
Constructor Details
#initialize(structure) ⇒ Typeform
Returns a new instance of Typeform.
6 7 8 |
# File 'lib/ask_awesomely/typeform.rb', line 6 def initialize(structure) @structure = structure end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/ask_awesomely/typeform.rb', line 4 def id @id end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
4 5 6 |
# File 'lib/ask_awesomely/typeform.rb', line 4 def links @links end |
#structure ⇒ Object (readonly)
Returns the value of attribute structure.
4 5 6 |
# File 'lib/ask_awesomely/typeform.rb', line 4 def structure @structure end |
Instance Method Details
#embed_as(type, options = {}) ⇒ Object
26 27 28 |
# File 'lib/ask_awesomely/typeform.rb', line 26 def (type, = {}) Embeddable.new(type).render(self, ) end |
#private_url ⇒ Object
20 21 22 23 24 |
# File 'lib/ask_awesomely/typeform.rb', line 20 def private_url @private_url ||= links.find {|link| link["rel"] == "self" }.fetch("href") end |
#public_url ⇒ Object
14 15 16 17 18 |
# File 'lib/ask_awesomely/typeform.rb', line 14 def public_url @public_url ||= links.find {|link| link["rel"] == "form_render" }.fetch("href") end |
#title ⇒ Object
10 11 12 |
# File 'lib/ask_awesomely/typeform.rb', line 10 def title @structure.class._state.title end |
#to_json ⇒ Object
35 36 37 |
# File 'lib/ask_awesomely/typeform.rb', line 35 def to_json @structure.to_json end |
#update_with_api_response(response) ⇒ Object
30 31 32 33 |
# File 'lib/ask_awesomely/typeform.rb', line 30 def update_with_api_response(response) @links = response["_links"] @id = response["id"] end |