Class: Styles::Properties::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/styles/properties/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/styles/properties/base.rb', line 6

def name
  @name
end

#selectorObject

Returns the value of attribute selector.



6
7
8
# File 'lib/styles/properties/base.rb', line 6

def selector
  @selector
end

#valueObject

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

Returns:

  • (Boolean)


39
40
41
# File 'lib/styles/properties/base.rb', line 39

def self.multiple_names?
  names.size > 1
end

.namesObject



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_enginesObject



8
9
10
# File 'lib/styles/properties/base.rb', line 8

def self.sub_engines
  @sub_engines ||= []
end

.to_symObject

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

Instance Method Details

#colorsObject



47
48
49
# File 'lib/styles/properties/base.rb', line 47

def colors
  ::Styles::Colors
end