Class: AskAwesomely::Typeform
- Inherits:
-
Object
- Object
- AskAwesomely::Typeform
- Defined in:
- lib/ask_awesomely/typeform.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#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.
5 6 7 8 |
# File 'lib/ask_awesomely/typeform.rb', line 5 def initialize(structure) @structure = structure @fields = [] end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
3 4 5 |
# File 'lib/ask_awesomely/typeform.rb', line 3 def fields @fields end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/ask_awesomely/typeform.rb', line 3 def id @id end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
3 4 5 |
# File 'lib/ask_awesomely/typeform.rb', line 3 def links @links end |
#structure ⇒ Object (readonly)
Returns the value of attribute structure.
3 4 5 |
# File 'lib/ask_awesomely/typeform.rb', line 3 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 do |link| link['rel'] == 'self' end.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 do |link| link['rel'] == 'form_render' end.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
36 37 38 |
# File 'lib/ask_awesomely/typeform.rb', line 36 def to_json @structure.to_json end |
#update_with_api_response(response) ⇒ Object
30 31 32 33 34 |
# File 'lib/ask_awesomely/typeform.rb', line 30 def update_with_api_response(response) @links = response['_links'] @id = response['id'] @fields = response['fields'] end |