Class: Sapling::CssGenerator
- Inherits:
-
Object
- Object
- Sapling::CssGenerator
- Defined in:
- lib/sapling/generators/css_generator.rb
Instance Attribute Summary collapse
-
#sapling ⇒ Object
Returns the value of attribute sapling.
Instance Method Summary collapse
- #css_class(feature, on) ⇒ Object
-
#initialize(sapling) ⇒ CssGenerator
constructor
A new instance of CssGenerator.
- #prefix ⇒ Object
-
#to_s(options = {}) ⇒ Object
see Sapling::API::Client for options.
Constructor Details
#initialize(sapling) ⇒ CssGenerator
Returns a new instance of CssGenerator.
7 8 9 |
# File 'lib/sapling/generators/css_generator.rb', line 7 def initialize(sapling) @sapling=sapling end |
Instance Attribute Details
#sapling ⇒ Object
Returns the value of attribute sapling.
5 6 7 |
# File 'lib/sapling/generators/css_generator.rb', line 5 def sapling @sapling end |
Instance Method Details
#css_class(feature, on) ⇒ Object
15 16 17 |
# File 'lib/sapling/generators/css_generator.rb', line 15 def css_class(feature, on) "#{prefix}_#{feature.to_s}_#{on ? 'on' : 'off'}" end |
#prefix ⇒ Object
11 12 13 |
# File 'lib/sapling/generators/css_generator.rb', line 11 def prefix "sapling_css" end |
#to_s(options = {}) ⇒ Object
see Sapling::API::Client for options
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sapling/generators/css_generator.rb', line 20 def to_s(={}) features = Set.new @sapling.features active_features = Set.new @sapling.active_features inactive_features = features - active_features [ active_features.collect {|f|".#{css_class(f, false)} { display:none !important; }"}, inactive_features.collect {|f|".#{css_class(f, true)} { display:none !important; }"}, ].flatten.join("\n") end |