Class: AskAwesomely::Typeform

Inherits:
Object
  • Object
show all
Defined in:
lib/ask_awesomely/typeform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/ask_awesomely/typeform.rb', line 4

def id
  @id
end

Returns the value of attribute links.



4
5
6
# File 'lib/ask_awesomely/typeform.rb', line 4

def links
  @links
end

#structureObject (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 embed_as(type, options = {})
  Embeddable.new(type).render(self, options)
end

#private_urlObject



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_urlObject



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

#titleObject



10
11
12
# File 'lib/ask_awesomely/typeform.rb', line 10

def title
  @structure.class._state.title
end

#to_jsonObject



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