Class: Moo::Model::TextData
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alignment ⇒ Object
Returns the value of attribute alignment.
-
#colour ⇒ Object
Returns the value of attribute colour.
-
#font ⇒ Object
Returns the value of attribute font.
-
#point_size ⇒ Object
Returns the value of attribute point_size.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from Data
Instance Method Summary collapse
- #from_json(json) ⇒ Object
-
#initialize {|_self| ... } ⇒ TextData
constructor
A new instance of TextData.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from Data
Constructor Details
#initialize {|_self| ... } ⇒ TextData
Returns a new instance of TextData.
9 10 11 |
# File 'lib/moo/model/text_data.rb', line 9 def initialize yield self if block_given? end |
Instance Attribute Details
#alignment ⇒ Object
Returns the value of attribute alignment.
6 7 8 |
# File 'lib/moo/model/text_data.rb', line 6 def alignment @alignment end |
#colour ⇒ Object
Returns the value of attribute colour.
6 7 8 |
# File 'lib/moo/model/text_data.rb', line 6 def colour @colour end |
#font ⇒ Object
Returns the value of attribute font.
6 7 8 |
# File 'lib/moo/model/text_data.rb', line 6 def font @font end |
#point_size ⇒ Object
Returns the value of attribute point_size.
6 7 8 |
# File 'lib/moo/model/text_data.rb', line 6 def point_size @point_size end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/moo/model/text_data.rb', line 7 def text @text end |
Instance Method Details
#from_json(json) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/moo/model/text_data.rb', line 58 def from_json json hash = JSON.parse(json, :symbolize_names => true) self.link_id = hash[:linkId] self.text = hash[:text] self.point_size = hash[:pointSize] self.alignment = hash[:alignment].to_sym self.font = Font.new self.font.from_json(hash[:font].to_json) self.colour = Colour.new self.colour.from_json(hash[:colour].to_json) end |
#to_hash ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/moo/model/text_data.rb', line 45 def to_hash hash = { :type => type, :linkId => link_id, :text => text } hash[:pointSize] = point_size unless point_size.nil? hash[:alignment] = alignment unless point_size.nil? hash[:font] = font.to_hash unless font.nil? hash[:colour] = colour.to_hash unless colour.nil? hash end |
#to_json ⇒ Object
41 42 43 |
# File 'lib/moo/model/text_data.rb', line 41 def to_json to_hash.to_json end |