Method: Faq::Section#initialize

Defined in:
app/models/faq.rb

#initialize(args) ⇒ Section

Returns a new instance of Section.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/faq.rb', line 7

def initialize args
  @name = args[:name]
  @items = args[:item].map do |v|
    if ['subtitle'] == v.keys
      Subtitle.new v['subtitle']
    elsif ['q', 'a'] == v.keys
      QAPair.new q: v['q'], a: v['a']
    else
      raise "Item #{v} did not match subtitle or QApair format"
    end
  end
end