Class: Rubytypeformio::ChoiceField

Inherits:
Field
  • Object
show all
Defined in:
lib/rubytypeformio/choice_field.rb

Instance Attribute Summary collapse

Attributes inherited from Field

#description, #id, #question, #required, #type

Instance Method Summary collapse

Methods inherited from Field

from_json, #to_json

Methods inherited from Base

#compact, #pretty

Constructor Details

#initialize(question, description, required, type, choices) ⇒ ChoiceField

Returns a new instance of ChoiceField.



9
10
11
12
# File 'lib/rubytypeformio/choice_field.rb', line 9

def initialize (question, description, required, type, choices)
  super(question, description, required, type)
  @choices = choices
end

Instance Attribute Details

#choicesObject

Returns the value of attribute choices.



7
8
9
# File 'lib/rubytypeformio/choice_field.rb', line 7

def choices
  @choices
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
20
21
22
# File 'lib/rubytypeformio/choice_field.rb', line 14

def to_h
  hash = super.to_h

  hash[:choices] = []
  @choices.each { |c|
    hash[:choices].push(c.to_h)
  }
  return hash
end