Class: Rubytypeformio::Choice

Inherits:
Base
  • Object
show all
Defined in:
lib/rubytypeformio/choice.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#compact, #pretty

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_idObject

Returns the value of attribute image_id.



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

def image_id
  @image_id
end

#labelObject

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_hObject



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_jsonObject



13
14
15
# File 'lib/rubytypeformio/choice.rb', line 13

def to_json
  JSON.dump(self.to_h)
end