Class: CSS::FontProperty
- Defined in:
- lib/css/properties/font_property.rb
Instance Method Summary collapse
Methods inherited from Property
#<<, #==, #[], create, #get, #initialize, #inspect, #method_missing, #value
Methods included from Normalize
Constructor Details
This class inherits a constructor from CSS::Property
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CSS::Property
Instance Method Details
#name ⇒ Object
3 4 5 |
# File 'lib/css/properties/font_property.rb', line 3 def name 'font' end |
#to_s ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/css/properties/font_property.rb', line 7 def to_s if size && family %w(style variant weight size family).map do |prop| if @properties[prop] != default_properties[prop] if prop == 'size' && get('size') != nil && @properties['line-height'] [@properties[prop], @properties['line-height']].join('/') else @properties[prop] end else nil end end.compact.join(' ') end end |
#to_style ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/css/properties/font_property.rb', line 23 def to_style if size && family values = %w(style variant weight size family).map do |prop| if @properties[prop] != default_properties[prop] if prop == 'size' && get('size') != nil && @properties['line-height'] [@properties[prop], @properties['line-height']].join('/') else @properties[prop] end else nil end end.compact.join(' ') [name, values].join(':') else @properties.map { |prop, val| "#{prop == 'line-height' ? '' : 'font-'}#{prop}:#{val}" }.join(';') end end |