Class: Rubytypeformio::Choice
Instance Attribute Summary collapse
-
#image_id ⇒ Object
Returns the value of attribute image_id.
-
#label ⇒ Object
Returns the value of attribute label.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(label) ⇒ Choice
constructor
A new instance of Choice.
- #to_h ⇒ Object
- #to_json ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(label) ⇒ Choice
Returns a new instance of Choice.
9 10 11 |
# File 'lib/rubytypeformio/choice.rb', line 9 def initialize (label) @label = label end |
Instance Attribute Details
#image_id ⇒ Object
Returns the value of attribute image_id.
7 8 9 |
# File 'lib/rubytypeformio/choice.rb', line 7 def image_id @image_id end |
#label ⇒ Object
Returns the value of attribute label.
7 8 9 |
# File 'lib/rubytypeformio/choice.rb', line 7 def label @label end |
Class Method Details
.from_json(string) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/rubytypeformio/choice.rb', line 24 def self.from_json(string) data = JSON.load(string) obj = self.new( data["label"]) if (data["image_id"]) obj.image_id = data["image_id"] end return obj end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rubytypeformio/choice.rb', line 17 def to_h return { :image_id => @image_id, :label => @label } end |
#to_json ⇒ Object
13 14 15 |
# File 'lib/rubytypeformio/choice.rb', line 13 def to_json JSON.dump(self.to_h) end |