Class: Moo::Model::Font

Inherits:
Object show all
Defined in:
lib/moo/model/font.rb

Constant Summary collapse

ACCEPTED_FAMILIES =
[
  'arial',
  'avantgarde',
  'bryant',
  'courier',
  'frutigerltpro',
  'georgia',
  'helv',
  'helvetica',
  'index',
  'meta',
  'officina',
  'radio',
  'router',
  'vagrounded'
]
@@default_family =
'helvetica'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Font.

Yields:

  • (_self)

Yield Parameters:



26
27
28
29
30
31
# File 'lib/moo/model/font.rb', line 26

def initialize
  @family = @@default_family
  @bold = false
  @italic = false
  yield self if block_given?
end

Instance Attribute Details

#boldObject Also known as: bold?

Returns the value of attribute bold.



5
6
7
# File 'lib/moo/model/font.rb', line 5

def bold
  @bold
end

#familyObject

Returns the value of attribute family.



5
6
7
# File 'lib/moo/model/font.rb', line 5

def family
  @family
end

#italicObject Also known as: italic?

Returns the value of attribute italic.



5
6
7
# File 'lib/moo/model/font.rb', line 5

def italic
  @italic
end

Instance Method Details

#from_json(json) ⇒ Object



58
59
60
61
62
63
# File 'lib/moo/model/font.rb', line 58

def from_json(json)
  hash = JSON.parse(json, :symbolize_names => true)
  @family = hash[:fontFamily]
  @bold   = hash[:bold]
  @italic = hash[:italic]
end

#to_hashObject



50
51
52
53
54
55
56
# File 'lib/moo/model/font.rb', line 50

def to_hash
  {
    :fontFamily => @family,
    :bold       => @bold,
    :italic     => @italic
  }
end

#to_jsonObject



46
47
48
# File 'lib/moo/model/font.rb', line 46

def to_json
  to_hash.to_json
end