Class: Moo::Model::Font
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
-
#bold ⇒ Object
(also: #bold?)
Returns the value of attribute bold.
-
#family ⇒ Object
Returns the value of attribute family.
-
#italic ⇒ Object
(also: #italic?)
Returns the value of attribute italic.
Instance Method Summary collapse
- #from_json(json) ⇒ Object
-
#initialize {|_self| ... } ⇒ Font
constructor
A new instance of Font.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Font
Returns a new instance of Font.
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
#bold ⇒ Object 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 |
#family ⇒ Object
Returns the value of attribute family.
5 6 7 |
# File 'lib/moo/model/font.rb', line 5 def family @family end |
#italic ⇒ Object 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_hash ⇒ Object
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_json ⇒ Object
46 47 48 |
# File 'lib/moo/model/font.rb', line 46 def to_json to_hash.to_json end |