Class: RailsFancies::FancyFaqHelper::FancyFaq

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails_fancies/fancy_faq_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#question_listObject

Returns the value of attribute question_list

Returns:

  • (Object)

    the current value of question_list



8
9
10
# File 'lib/rails_fancies/fancy_faq_helper.rb', line 8

def question_list
  @question_list
end

#viewObject

Returns the value of attribute view

Returns:

  • (Object)

    the current value of view



8
9
10
# File 'lib/rails_fancies/fancy_faq_helper.rb', line 8

def view
  @view
end

Instance Method Details

#answer(name, text) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_fancies/fancy_faq_helper.rb', line 19

def answer(name, text)
  if question_list[name.to_sym].present?
     :div, class: 'faq_answer' do
      (:a, '', name: "#{name}") +
        (:div, question_list[name.to_sym], class: 'faq_answer_heading') +
        (:p, "#{text}", class: 'faq_answers')
    end
  else
    raise "No question was found with a name of :#{name}"
  end
end

#question(name, text) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rails_fancies/fancy_faq_helper.rb', line 10

def question(name, text)
  add_to_list question_list, name, text
   :div, class: 'faq_question' do
     :a, href: "##{name}" do
      "#{text}"
    end
  end
end