Class: Fdbq::Question

Inherits:
Object
  • Object
show all
Defined in:
lib/fdbq/question.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Question

Returns a new instance of Question.



5
6
7
8
9
# File 'lib/fdbq/question.rb', line 5

def initialize(attrs = {})
  attrs.to_h.each_pair do |k, v|
    self.send("#{k}=", v)
  end
end

Instance Attribute Details

#hintObject

Returns the value of attribute hint.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def hint
  @hint
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def label
  @label
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def name
  @name
end

#placeholderObject

Returns the value of attribute placeholder.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def placeholder
  @placeholder
end

#requiredObject

Returns the value of attribute required.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def required
  @required
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def type
  @type
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/fdbq/question.rb', line 3

def value
  @value
end

Instance Method Details

#answered?(answers) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/fdbq/question.rb', line 15

def answered?(answers)
  answers.to_h.stringify_keys[param_key].present?
end

#param_keyObject



11
12
13
# File 'lib/fdbq/question.rb', line 11

def param_key
  name.to_s
end

#required?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fdbq/question.rb', line 19

def required?
  !!required
end