Class: Styles::Properties::Base
- Inherits:
-
Object
- Object
- Styles::Properties::Base
- Defined in:
- lib/styles/properties/base.rb
Direct Known Subclasses
BackgroundColor, Border, Color, Display, FontWeight, Function, Margin, MatchBackgroundColor, MatchColor, MatchFontWeight, MatchTextDecoration, Padding, TextAlign, TextDecoration, Width
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
- .multiple_names? ⇒ Boolean
- .names ⇒ Object
-
.other_names(*names) ⇒ Object
Macro to specify other names that a property class uses, besides the main
to_sym
version. -
.sub_engine(name) ⇒ Object
Macro to specify a sub-engine that this property is processed by.
- .sub_engines ⇒ Object
-
.to_sym ⇒ Object
The name of this property, for use in stylesheets, as a Symbol.
Instance Method Summary collapse
- #colors ⇒ Object
-
#initialize(selector, name, value) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(selector, name, value) ⇒ Base
Returns a new instance of Base.
43 44 45 |
# File 'lib/styles/properties/base.rb', line 43 def initialize(selector, name, value) @selector, @name, @value = selector, name, value end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/styles/properties/base.rb', line 6 def name @name end |
#selector ⇒ Object
Returns the value of attribute selector.
6 7 8 |
# File 'lib/styles/properties/base.rb', line 6 def selector @selector end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/styles/properties/base.rb', line 6 def value @value end |
Class Method Details
.multiple_names? ⇒ Boolean
39 40 41 |
# File 'lib/styles/properties/base.rb', line 39 def self.multiple_names? names.size > 1 end |
.names ⇒ Object
35 36 37 |
# File 'lib/styles/properties/base.rb', line 35 def self.names @names ||= [to_sym, instance_variable_get('@other_names')].flatten.compact end |
.other_names(*names) ⇒ Object
Macro to specify other names that a property class uses, besides the main to_sym
version
30 31 32 33 |
# File 'lib/styles/properties/base.rb', line 30 def self.other_names(*names) @other_names = names @names = self.names end |
.sub_engine(name) ⇒ Object
Macro to specify a sub-engine that this property is processed by
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/styles/properties/base.rb', line 13 def self.sub_engine(name) sub_engine_class = ::Styles::SubEngines.const_get(camelize(name.to_s)) sub_engines << sub_engine_class begin include sub_engine_class::PropertyMixin rescue NameError # do nothing if PropertyMixin does not exist for SubEngine end end |
.sub_engines ⇒ Object
8 9 10 |
# File 'lib/styles/properties/base.rb', line 8 def self.sub_engines @sub_engines ||= [] end |
.to_sym ⇒ Object
The name of this property, for use in stylesheets, as a Symbol
25 26 27 |
# File 'lib/styles/properties/base.rb', line 25 def self.to_sym underscore(name).split('/').last.to_sym end |