Class: Smartdown::Api::Question
- Inherits:
-
Object
- Object
- Smartdown::Api::Question
show all
- Defined in:
- lib/smartdown/api/question.rb
Instance Method Summary
collapse
Constructor Details
#initialize(elements) ⇒ Question
Returns a new instance of Question.
5
6
7
|
# File 'lib/smartdown/api/question.rb', line 5
def initialize(elements)
@elements = elements
end
|
Instance Method Details
#body ⇒ Object
17
18
19
20
|
# File 'lib/smartdown/api/question.rb', line 17
def body
elements_before_smartdown = elements[1..-1].take_while{|element| !smartdown_element?(element)}
build_govspeak(elements_before_smartdown)
end
|
#hint ⇒ Object
31
32
|
# File 'lib/smartdown/api/question.rb', line 31
def hint
end
|
#name ⇒ Object
13
14
15
|
# File 'lib/smartdown/api/question.rb', line 13
def name
elements.find{ |element| element.class.to_s.include?("Smartdown::Model::Element::Question") }.name
end
|
#post_body ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/smartdown/api/question.rb', line 22
def post_body
elements_after_smartdown = elements.select{ |element| !next_node_element?(element) }
.reverse
.take_while{|element| !smartdown_element?(element)}
.reverse
build_govspeak(elements_after_smartdown)
end
|
#title ⇒ Object
9
10
11
|
# File 'lib/smartdown/api/question.rb', line 9
def title
elements.first.content
end
|