Class: Rubytypeformio::Field
Direct Known Subclasses
ChoiceField, EmailField, LegalField, LongTextField, NumberField, OpinionField, RatingField, ShortTextField, StatementField, WebsiteField, YesNoField
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#question ⇒ Object
Returns the value of attribute question.
-
#required ⇒ Object
Returns the value of attribute required.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(question, description, required, type) ⇒ Field
constructor
A new instance of Field.
- #to_h ⇒ Object
- #to_json ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(question, description, required, type) ⇒ Field
Returns a new instance of Field.
9 10 11 12 13 14 |
# File 'lib/rubytypeformio/field.rb', line 9 def initialize (question, description, required, type) @description = description @question = question @required = required @type = type end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/rubytypeformio/field.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/rubytypeformio/field.rb', line 7 def id @id end |
#question ⇒ Object
Returns the value of attribute question.
7 8 9 |
# File 'lib/rubytypeformio/field.rb', line 7 def question @question end |
#required ⇒ Object
Returns the value of attribute required.
7 8 9 |
# File 'lib/rubytypeformio/field.rb', line 7 def required @required end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/rubytypeformio/field.rb', line 7 def type @type end |
Class Method Details
.from_json(string) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rubytypeformio/field.rb', line 30 def self.from_json(string) data = JSON.load(string) obj = self.new( data["description"], data["question"], data["required"], data["type"] ) obj.id = data["id"] return obj end |
Instance Method Details
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/rubytypeformio/field.rb', line 20 def to_h hash = { :description => @description, :question => @question, :required => @required, :type => @type, :id => @id, } end |
#to_json ⇒ Object
16 17 18 |
# File 'lib/rubytypeformio/field.rb', line 16 def to_json JSON.dump(self.to_h) end |