Class: Moo::Model::TextData

Inherits:
Data show all
Defined in:
lib/moo/model/text_data.rb

Direct Known Subclasses

MultiLineTextData

Instance Attribute Summary collapse

Attributes inherited from Data

#link_id

Instance Method Summary collapse

Methods inherited from Data

#type

Constructor Details

#initialize {|_self| ... } ⇒ TextData

Returns a new instance of TextData.

Yields:

  • (_self)

Yield Parameters:



9
10
11
# File 'lib/moo/model/text_data.rb', line 9

def initialize
  yield self if block_given?
end

Instance Attribute Details

#alignmentObject

Returns the value of attribute alignment.



6
7
8
# File 'lib/moo/model/text_data.rb', line 6

def alignment
  @alignment
end

#colourObject

Returns the value of attribute colour.



6
7
8
# File 'lib/moo/model/text_data.rb', line 6

def colour
  @colour
end

#fontObject

Returns the value of attribute font.



6
7
8
# File 'lib/moo/model/text_data.rb', line 6

def font
  @font
end

#point_sizeObject

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

#textObject

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_hashObject



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_jsonObject



41
42
43
# File 'lib/moo/model/text_data.rb', line 41

def to_json
  to_hash.to_json
end